Short version: The evaluator-optimizer pattern has one agent generate output while another evaluates it and gives feedback, in a loop. Anthropic calls it evaluator-optimizer. Google splits the same idea into a generator-critic loop for correctness and an iterative refinement loop for quality. Both live or die by their exit condition.
What is the evaluator-optimizer?
In the evaluator-optimizer workflow, one LLM call generates a response while another provides evaluation and feedback in a loop (Anthropic). Google frames it as two specialized agents: a generator creates an output, and a critic evaluates it against set criteria, then approves it, rejects it, or returns it with feedback for revision (Google Cloud).
It mirrors how a writer works: draft, get notes, revise, repeat until it is good.
Two flavors of the same loop
Google draws a line worth keeping (Google Developers):
- Generator-critic focuses on correctness. The critic returns a pass or fail against hard criteria, such as valid syntax or passing unit tests. On a pass, the loop breaks. On a fail, specific feedback goes back to the generator.
- Iterative refinement focuses on quality. A generator drafts, a critic suggests optimizations, and a refiner rewrites. It repeats to polish, not just to pass.
Both are implementations of a loop agent, and both need a way out (Google Cloud).
# Google ADK, sketch
generator = LlmAgent(name="Generator", instruction="Draft. If {feedback}, fix it.", output_key="draft")
critic = LlmAgent(name="Critic", instruction="Check {draft}. Output PASS or the errors.", output_key="feedback")
loop = LoopAgent(sub_agents=[generator, critic], exit_condition="PASS")
How it actually works
The generator produces a draft. The critic evaluates it against explicit criteria and either approves it or sends feedback. The loop repeats until the output passes or hits an iteration cap. In ADK you can set a hard limit with a maximum iteration count, and an agent can also signal early completion when the quality bar is met before the cap (Google Developers).
When to use it
Anthropic gives two clear signals of fit: an answer that measurably improves when a human articulates feedback, and a model that can produce that kind of feedback itself (Anthropic). If both hold, a critic loop tends to pay off. Anthropic's example is literary translation, where the first pass misses nuance an evaluator can catch, and complex search, where the evaluator decides whether more searching is warranted.
Google's version fits tasks where output must be highly accurate or must meet strict constraints before use, such as a generator writing code and a critic auditing it for vulnerabilities or checking that it passes tests (Google Cloud).
When not to use it
Do not use it when you have no reliable way to judge good from bad. The loop becomes circular when the evaluator cannot tell a good output from a weak one, and you spend calls without converging. Do not use it when a single pass is already good enough, since the extra critic call is pure overhead. And avoid it for latency-critical paths, because each cycle adds at least one more model call.
Known problems
The direct cost is latency and money. The workflow needs at least one extra model call for the critic, and if revision loops kick in, both latency and cost accumulate with each iteration (Google Cloud).
The dangerous failure is the loop that never ends. Google warns that if the termination condition is not defined correctly, or the subagents never produce the state that stops the loop, it can run indefinitely, leading to excessive cost, high resource use, and potential system hangs (Google Cloud). A maximum iteration count is not optional, it is the safety belt.
Three things to know before you start
- Always cap the iterations. A hard limit prevents runaway cost and hangs, even when your quality check is imperfect.
- Make the criteria explicit. The critic can only enforce standards you spell out. Vague criteria produce vague critiques.
- Pick your flavor. Pass or fail for correctness, iterative rewrite for quality. They want different exit conditions.
FAQ
Is evaluator-optimizer the same as generator-critic?
They are the same loop. Anthropic uses "evaluator-optimizer." Google splits it into a generator-critic loop for correctness and iterative refinement for quality.
How do I avoid an infinite loop?
Set a maximum number of iterations and a clear exit condition. Optionally let the agent signal early completion when the quality bar is met.
When does this pattern actually help?
When feedback demonstrably improves the output and the model can generate that feedback. If either is missing, the loop wastes calls.
Is this the same as chain-of-thought?
No. Chain-of-thought is reasoning inside one call. This pattern uses a separate evaluation step and can loop across multiple calls.
Sources
- Anthropic, Building Effective Agents: https://www.anthropic.com/engineering/building-effective-agents
- Google Developers Blog, Developer's guide to multi-agent patterns in ADK: https://developers.googleblog.com/developers-guide-to-multi-agent-patterns-in-adk/
- Google Cloud Architecture Center, Choose a design pattern for your agentic AI system: https://docs.cloud.google.com/architecture/choose-design-pattern-agentic-ai-system

Top comments (0)