This post describes a generate, validate, and retry pattern. The earlier production-test claims are unsupported by a published methodology or dataset and have been removed. The examples below are guidance, not measured results.
Example Tasks
Possible tasks for evaluating this pattern include:
- A support ticket classification agent
- A CRM data entry agent
- An appointment scheduling agent
- A document summarization agent
For an evaluation, define errors before running it: wrong tool calls, malformed outputs, missing fields, and incorrect classifications. Record a baseline on a fixed task set.
Patterns to Compare
These twelve pattern ideas fall into three categories; they are not a ranked benchmark:
Category 1: Instruction Patterns
- Chain-of-thought (explain your reasoning)
- Role framing (act as an expert X)
- Negative constraints (do not do X)
- Few-shot examples (show 3 examples)
Category 2: Output Constraints
- JSON schema enforcement
- Output format templates
- Enum-style field constraints
- Length limits (max N words)
Category 3: Process Patterns
- Self-correction loop (generate, review, fix)
- Step-by-step checklist
- Validation loop (generate, validate, retry)
- Debate pattern (generate two answers, pick one)
How to Evaluate
Compare the validation loop with a single-pass baseline on the same tasks. Record error categories, retry counts, and end-to-end latency; improvement is not guaranteed.
What the Validation Loop Looks Like
Here is an illustrative prompt in three phases. A model reviewing its own output is not an independent check of factual accuracy:
# Phase 1: Generate
Based on the user's request, produce the appropriate output.
# Phase 2: Validate
Review your output against these criteria:
- Does it match the expected schema?
- Are all required fields present?
- Is the content accurate given the context?
- Would a reasonable user expect this response?
# Phase 3: Correct (if needed)
If any validation check fails, revise the output.
If all checks pass, output: [VALID]
For example, cap the loop at three attempts and route unresolved failures to a human with the validation errors. Enforce the cap and any schema checks in code, not just in the prompt.
What to Check
Evaluate these potential uses and limitations:
- Check output format before downstream use. A deterministic schema validator can reject missing fields; a prompted self-review alone does not enforce a schema.
- Do not treat self-review as independent QA. The model can repeat its original mistake. Check factual claims against trusted evidence.
- Provide specific feedback for retries. Pass validator errors to the next attempt and verify the revised output again.
"Generate, validate, and retry is a workflow to evaluate, not a guarantee of correctness."
Implementation Tips
If you want to try this pattern, here are a few practical notes:
- Set a max retry count. For example, allow three attempts, then escalate. The model will not fix fundamental misunderstandings through sheer repetition.
- Log every validation failure. You will find patterns in what your agent gets wrong. Use that to improve your validation criteria.
- Keep validation criteria specific. "Is this correct?" is useless. "Does the email_address field match the regex pattern?" is actionable.
- Account for latency. Extra calls and retries can add latency. Measure the end-to-end cost on your workload; checks that gate external actions must finish before those actions occur.
The Bottom Line
A validation loop adds checks, retries, and complexity. Whether it reduces errors enough to justify that cost must be established with an evaluation of your own workload.
Prompt engineering is often about finding the right words. Sometimes, though, it is about finding the right process. A validation loop provides a feedback mechanism; its usefulness depends on the checks and the task.
Quick start: Try a validation phase on a fixed set of representative tasks. Compare it with a single-pass baseline, log failures, and review regressions before using it for consequential actions.
Sources linked November 9, 2026. Each link was requested that day and is limited to the point named here.
Sources
- OpenAI Structured Outputs. Structured Outputs makes the model follow a supplied JSON Schema so a response does not omit a required key or invent an invalid enum value. Schema adherence is enforced by the API, which matches the post's point that a schema check belongs in code rather than only in a prompt.
- OpenAI evals. OpenAI describes evals as tests of model outputs against style and content criteria you specify, run on test inputs, then analyzed and iterated. That matches the post's instruction to compare a validation loop with a single-pass baseline on a fixed task set.
- Building effective agents. Anthropic describes an evaluator-optimizer loop, programmatic checks between steps, and stopping conditions such as a maximum number of iterations, and says to add complexity only when evaluation shows it improves outcomes.
Related Guide
See the OpenClaw Field Guide for related agent-building guidance. Check the product page and preview before buying.
Get the Field Guide — $10 →