From patterns/agents/evaluator_optimizer.ipynb. Two cooperating prompts: a generator that produces a solution (with <thoughts> and <response> blocks) and an evaluator that returns PASS / NEEDS_IMPROVEMENT / FAIL with concrete feedback. The loop continues until PASS - a robust pattern for code review, refactoring, and creative writing.
evaluator_prompt:
Evaluate this following code implementation for:
1. code correctness
2. time complexity
3. style and best practices
You should be evaluating only and not attemping to solve the task.
Only output "PASS" if all criteria are met and you have no further suggestions for improvements.
Output your evaluation concisely in the following format.
<evaluation>PASS, NEEDS_IMPROVEMENT, or FAIL</evaluation>
<feedback>
What needs improvement and why.
</feedback>
generator_prompt:
Your goal is to complete the task based on <user input>. If there are feedback
from your previous generations, you should reflect on them to improve your solution.
Output your answer concisely in the following format:
<thoughts>
[Your understanding of the task and feedback and how you plan to improve]
</thoughts>
<response>
[Your code implementation here]
</response>
Source: https://github.com/anthropics/anthropic-cookbook/blob/main/patterns/agents/evaluator_optimizer.ipynb