Evaluator-Optimizer Pattern

In this pattern, one step generates a result and another evaluates it against explicit criteria. The result can be revised until it passes or a retry limit is reached.

Use objective criteria

“Make it better” is weak. Evaluate specific properties such as completeness, citation coverage, schema validity, safety, or test results.

Set a loop budget

Evaluator loops can continue indefinitely if the criteria are subjective. Cap retries and surface unresolved failures.

Strong use cases

Code generation with tests, document quality checks, extraction validation, and research answers with citation requirements.