Testing AI Agent Loops
Agent loops that run tests, isolate failures, fix regressions, and stop only when verification passes. Every page is server-rendered, source-aware, and includes a copy-ready Markdown protocol.
All Testing loops
Test Until Green
Run the project test suite, fix root causes, and keep iterating until the selected test command passes.
Kickoff preview
Run the project tests, inspect failures, fix the smallest root cause, and repeat until the test command passes. Do not weaken the tests or change the check command. Goal: Make the selected test command pass without weakening coverage. Check command: pnpm test Exit condition: The test command exits successfully with no failing tests. Max iterations: 8 Guardrails: - Do not weaken, skip, delete, or rewrite the validation command to force success. - Do not claim completion until the stated exit condition is actually satisfied. - If blocked, report the blocker, evidence, and next safest action instead of gaming the metric. - Do not delete, skip, or mark tests as todo unless explicitly requested.
Fix TypeScript Until Clean
Run TypeScript checking, fix typed root causes, and stop only when strict type validation passes.
Kickoff preview
Run the TypeScript check, group errors by root cause, fix them with strict types, and repeat until the command exits cleanly. Goal: Make TypeScript validation pass without lowering type safety. Check command: pnpm tsc --noEmit Exit condition: TypeScript check exits with code 0. Max iterations: 8 Guardrails: - Do not weaken, skip, delete, or rewrite the validation command to force success. - Do not claim completion until the stated exit condition is actually satisfied. - If blocked, report the blocker, evidence, and next safest action instead of gaming the metric. - Do not add `any`, `// @ts-ignore`, or disable strict compiler options unless explicitly approved.
Build Until Passing
Run the production build, fix compile/runtime bundling failures, and stop only when the build succeeds.
Kickoff preview
Run the production build, fix root causes while preserving project architecture, and repeat until the build passes. Goal: Make the production build succeed for the target runtime. Check command: pnpm build Exit condition: The production build command exits successfully. Max iterations: 6 Guardrails: - Do not weaken, skip, delete, or rewrite the validation command to force success. - Do not claim completion until the stated exit condition is actually satisfied. - If blocked, report the blocker, evidence, and next safest action instead of gaming the metric. - Do not hide build failures with dynamic imports or environment checks unless that is the correct runtime boundary.
Post-Edit Test Guard
After code edits, detect the affected surface and run the closest relevant validation before declaring completion.
Kickoff preview
After every code edit, list changed files, choose the closest meaningful validation, run it, and report evidence before claiming completion. Goal: Run the closest meaningful verification after edits and report evidence. Check command: git diff --name-only HEAD Exit condition: Relevant validation has been run and either passes or failures are reported with evidence. Max iterations: 4 Guardrails: - Do not weaken, skip, delete, or rewrite the validation command to force success. - Do not claim completion until the stated exit condition is actually satisfied. - If blocked, report the blocker, evidence, and next safest action instead of gaming the metric. - Do not say “not run” without explaining why no meaningful check exists.
Flaky Test Triage
Re-run failing tests, identify nondeterminism, isolate likely causes, and avoid masking flaky behavior.
Kickoff preview
Triage the flaky test: re-run narrowly, estimate reproduction, inspect nondeterminism sources, patch or document quarantine, and verify repeatedly. Goal: Diagnose flaky behavior without hiding it. Check command: pnpm test -- --runInBand Exit condition: The flake has a likely cause, a verified fix, or a documented quarantine recommendation. Max iterations: 6 Guardrails: - Do not weaken, skip, delete, or rewrite the validation command to force success. - Do not claim completion until the stated exit condition is actually satisfied. - If blocked, report the blocker, evidence, and next safest action instead of gaming the metric. - Do not delete or skip flaky tests just to make CI pass without documenting risk.
Why this category matters
Testing loops are useful because AI agents need explicit feedback gates and exit criteria. A plain prompt may produce a first draft; a loop tells the agent how to verify progress, handle failures, and stop with evidence.