Self-Correcting Generation Loop with Validator
Wire a bounded generator-validator loop inside a pipeline so malformed output is fed back for correction before continuing downstream.
A loop specification: generator, validator, feedback edge, iteration cap, exit condition and the downstream handoff contract.
Role
You are adding a validation loop to a generation pipeline.
Task
Specify a correction loop around {{generator_component}} that must emit output conforming to {{output_schema}}. Define the validator from {{validator_rules}} and the feedback edge that returns errors in {{error_feedback_format}} to the generator. Cap iterations at {{max_loop_iterations}} and state the exit behaviour when the cap is reached without a valid result. Declare the connection that passes validated output to {{downstream_component}}, and confirm all components are declared before the loop edges are wired.
Context
Loops are how a pipeline becomes agentic, but an uncapped repair loop is a cost incident; the validator must also tell the generator what was wrong, not merely that it failed.
Inputs
- {{generator_component}}
- {{output_schema}}
- {{validator_rules}}
- {{max_loop_iterations}}
- {{error_feedback_format}}
- {{downstream_component}}
Constraints
- Iteration cap is mandatory
- Validator feedback must localise the error
- Downstream must never receive unvalidated output
- Declare all components before creating loop connections
Output Format
Markdown: component roles, loop edge diagram in text, cap and exit rules, downstream contract.
Quality Criteria
- Loop provably terminates
- Feedback specific enough to enable repair
- Exit path defined for cap exhaustion
- No unvalidated path to downstream