Why a loop?
Think about what happens without one. An agent writes code, declares victory, and moves on. Nobody checked if it compiles. Nobody checked if the logic is sound. You are trusting a single pass from a model that hallucinates sometimes. Now think about what happens with one. The agent writes code, a separate agent runs the tests, two more agents review the result, and a fixer addresses every issue. Then the whole thing repeats until both reviewers sign off — or you hit a safety cap. That is the implement-review loop. Four steps, one<Loop>, zero unsupervised merges.
The four steps
Each iteration runs these in sequence:- Implement — An agent writes code (preferably Codex).
- Validate — A separate agent runs tests to verify correctness.
- Review — Two agents review in parallel (Claude + Codex).
- ReviewFix — An agent addresses every review issue.
maxIterations is hit.
Minimal Example
Before wiring up the loop, you need schemas. One per step:The ValidationLoop Component
Here is the core pattern. Read it top to bottom — it is a<Loop> wrapping a <Sequence> of four components:
until={allApproved}. That is a boolean derived from two separate review outputs. Not a vague “looks good” — a concrete, programmatic signal. The loop keeps going until both reviewers say yes, or three rounds pass, whichever comes first.
Parallel Multi-Agent Review
Why two reviewers? Because they catch different things. Claude is strong on architecture and logic. Codex is strong on code correctness and edge cases. Running them in parallel costs wall-clock time equal to the slower one — not the sum. UsecontinueOnFail so one reviewer timing out does not block the other:
null. No point reviewing code that does not pass tests. The loop skips review entirely and cycles back to Implement.
Feeding Review Feedback Back to Implement
This is where the loop earns its keep. On the second (and third) iteration, the Implement component reads previous review issues and validation failures, then hands them to the agent:reviewIssues is empty and previousImplementation is null. The agent starts fresh. On subsequent iterations, it gets a structured list of everything that went wrong. No ambiguity, no lost context.
ReviewFix with skipIf
What if both reviewers approved? Then there is nothing to fix. TheskipIf prop handles this cleanly:
until condition sees allApproved and stops. No wasted compute.
Why This Pattern Works
Five properties make this loop reliable in production:- Validation before review — No point reviewing code that does not compile or pass tests. If validation fails, the loop skips review and goes straight back to implement.
- Parallel review — Two different models catch different kinds of issues. Claude is strong on architecture and logic; Codex is strong on code correctness and edge cases.
- Structured issues — Review output uses a typed
issuesarray with severity, file, and description. This lets ReviewFix address each issue systematically instead of parsing free-text feedback. - Bounded iterations —
maxIterationsprevents infinite loops. UseonMaxReached: "return-last"to accept the best effort after the cap. - Resumable — Every step persists to SQLite. If the workflow crashes mid-loop, it resumes from the last incomplete task. Not from the beginning. From right where it stopped.
Next Steps
- Loop Component — All Loop props and iteration semantics.
- Dynamic Tickets — Generate tickets dynamically instead of hardcoding.
- Model Selection — Which models to use for each step.
- Patterns — Project structure and naming conventions.