Level 3 · Loop Engineering

Make Verification the Control Plane

Long-running agents only become reliable when the loop is governed by external evidence, not by the model’s confidence that it is finished.

Self-Reporting Is Not a Control Plane

The failure mode in advanced agent workflows is no longer that the model cannot write the code. It is that the agent can keep moving while the operator loses the ability to tell whether progress is real. Once you let agents run for hours, across worktrees, scheduled jobs, and sub-agents, natural-language status updates become telemetry theater. The loop needs a control plane, and that control plane should be verification.

Treat every autonomous run as a state machine: plan, implement, verify, review, archive. The agent can own transitions only when it produces evidence that another process can inspect. Unit tests, type checks, browser recordings, performance traces, benchmark deltas, log excerpts, hashes, and judge scores are state-transition artifacts. “Done” is not a sentence in the transcript. “Done” is a bundle of reproducible facts attached to the run.

This changes how you design prompts. You stop asking for effort and start asking for admissible proof. A good loop spec says: here is the goal, here are allowed tools, here are forbidden actions, here is the evidence format, here are the gates, here is where a human must decide. The model can improvise inside the box, but the box is enforced by code, hooks, tests, and artifacts.

Build The Harness Around Gates

Once verification is the control plane, the harness matters more than any individual prompt. Put durable rules in repository memory, but keep them small: architecture boundaries, “never edit” paths, known gotchas, test commands, local service startup, release constraints. Large generated instruction libraries bloat context and anchor the model to stale details. Curated gotchas beat encyclopedic memory because they are cheaper, sharper, and easier to obey.

Then enforce the rules outside the model. Pre-tool hooks should block destructive commands, protected directories, secret exposure, schema-changing migrations, and production-affecting operations unless the run is explicitly in a human validation zone. Post-tool hooks can require artifacts before the loop advances: test output saved to a file, browser screenshots written to an artifacts directory, benchmark JSON emitted with machine-readable thresholds.

The strongest pattern is to make verification a separate agent or process. The implementer agent should not be the only judge of its work. Use a verifier session with a fresh context to read the diff, run the commands, inspect browser output, and fail the run with a specific reason. For subjective criteria, use an LLM judge, but make it rubric-bound: score simplicity, scope control, consistency with existing patterns, and risk. Require binary pass or fail for loop continuation, plus short failure notes that the implementer can act on.

Evidence Should Be Reproducible

A long loop needs artifacts that survive the chat window. Save command logs, test summaries, screenshots, videos, traces, and benchmark outputs under a run id. Hash the important files with SHA-256 so a later reviewer can tell whether the agent actually ran the command it claims to have run or merely summarized an earlier attempt. This is not ceremony. It prevents the most expensive autonomous failure: a loop that optimizes against imagined state.

For frontend work, browser automation is often the real verifier. Have the agent start the app, visit the changed routes, capture screenshots or short recordings, check console errors, and verify text overflow, layout stability, and interaction states. For performance work, do not accept “I optimized the page.” Require before and after measurements, fixed hardware assumptions where possible, repeated samples, and an explicit threshold such as p95 route load under 50ms or bundle size below a defined budget.

For backend and infrastructure changes, make the evidence fit the risk. Unit tests and type checks are table stakes. Add contract tests for public interfaces, migration dry-runs for persistence changes, log queries for production-error sweeps, and benchmark fixtures for hot paths. If a loop touches payments, auth, permissions, data deletion, compliance, or customer-visible irreversible actions, it should enter a human validation zone. The agent may prepare the diff and evidence, but it may not cross the boundary.

Parallelize Work, Serialize Proof

Parallelism is where verification becomes non-negotiable. Worktrees, sandboxes, and sub-agents let you run multiple implementations, reviews, or triage passes at once without file conflicts or context contamination. Use them aggressively for independent tasks: variant generation, code review, log analysis, failing-test investigation, documentation sync, and refactor candidates. The cost is that you now have multiple plausible narratives of progress. Only artifacts should decide what gets merged.

A practical pattern is fan-out, converge, verify. Spawn several agents with the same spec but different constraints: smallest diff, highest test coverage, simplest architecture, fastest runtime. Each agent must return a patch plus evidence. A coordinator compares the artifacts, not the confidence. It can select one patch, cherry-pick pieces, or reject all variants if none pass the gates. This is especially useful for overnight work because the morning review becomes evidence inspection instead of transcript archaeology.

Do not parallelize the final authority. Merge decisions, irreversible operations, and taste-heavy calls need serialization. If quality is subjective, prefer augmentation over full automation: let agents produce options, critiques, and rubric scores, then route the final call to a human or a narrower reviewer. Loops are strongest when the definition of done is measurable. When taste dominates, the loop should prepare judgment, not impersonate it.

Control Cost By Routing Verification

Verification-first loops can burn tokens if every step uses the largest model and rereads the whole repo. Split the pipeline by cognitive load. Use stronger models for spec clarification, architecture tradeoffs, and ambiguous failures. Use cheaper models or deterministic tools for linting, test retries, formatting, log parsing, artifact indexing, and routine reviewer passes. Keep each session narrow: planning does not need the full test log, and validation does not need the entire brainstorming transcript.

Persistent memory should also be routed, not dumped. At the end of a failed run, a retrospective agent should extract only reusable lessons: commands that lied, flaky tests, hidden setup, project-specific traps, reviewer preferences, and thresholds. Write those into markdown memory as gotchas. Delete stale or generic notes. The memory file is not a diary. It is a small control surface that makes the next loop cheaper and less likely to repeat the same mistake.

The frontier workflow is not “agent works overnight and tells me what happened.” It is “agent works overnight inside a harness that records what happened, proves what changed, blocks what must not happen, and hands me only the decisions that remain human.” Verification is the control plane because it turns autonomy from a trust exercise into an engineering system.

Key takeaways

  • Define done as external evidence: tests, traces, screenshots, benchmark files, hashes, and rubric scores, not model status text.
  • Use hooks and state machines to enforce gates the model cannot talk its way around.
  • Keep persistent memory small and operational: project gotchas, forbidden actions, verification commands, and thresholds.
  • Parallelize implementation and review in sandboxes or worktrees, then serialize merge authority through artifact-based verification.
  • Use LLM judges only with tight rubrics and binary pass/fail outputs, and reserve human validation zones for irreversible or taste-heavy decisions.
  • Route cheap models and deterministic tools to routine verification so long loops stay economically viable.