Research

Jul 10, 2026Harsh Chandra

Designing Autonomous Agent Loops: Architecture Beyond Prompts

Product

Start free Enterprise inquiries

Career

We're actively hiring people to build specialized AI agent services together at mign

Automatically translated from the Japanese original.

Overview

AI adoption is moving beyond the era of the "human clock" — a person types a prompt and waits — into a phase where we design autonomous loops in which agents keep running with no one at the keyboard. Drawing on an internal presentation, this article lays out the structure of such a loop, built from five nodes (discovery, handoff, verification, persistence, and scheduling); the architecture that separates the Generator from the Evaluator; Stripe's example of merging 1,300 machine-generated PRs a week; and the operational circuit breakers that keep everything in check. The conclusion: as the cost of generation heads toward zero, what remains scarce is judgment. The task is to design loops equipped with a rigorous evaluator and checkpoints where humans can step in — and to do so as someone who intends to remain an engineer.

Note: This article is a written adaptation (restructured in manuscript form) of an internal presentation originally produced as a slide deck. Its subject is the design of a resilient, multi-agent "Generator–Evaluator" architecture that keeps writing, reviewing, and merging code even while you sleep.

The End of the "Human Clock"

AI, as traditionally used, ran on the "human clock." The agent waits for input, a person presses Enter, tokens are generated, and everything stops. Repeat. In June 2026, a turning point arrived: Peter Steinberger (OpenClaw), Boris Cherny (Claude Code), and Addy Osmani (Chrome) each independently, within the same week, converged on the same realization — the tools had crossed a threshold.

The essence of the shift is this: stop being the person who prompts the agent, and become the person who designs the system that does it for you. An autonomous loop engine has three properties: (1) it is triggered by a timer (it wakes up on a schedule), (2) it spawns parallel sub-agents (helpers), and (3) it feeds itself (yesterday's output becomes today's input).

The Four-Layer AI Protocol Stack

AI usage can be organized into four layers, and the higher the layer, the larger the blast radius of a failure.

LayerCore concernUnit of scopeBlast radius of failureThe human's role
Layer 1: PromptWhat you tell the modelOne exchangeAn obviously wrong answerTypist
Layer 2: ContextWhat goes into the windowOne sessionConfidently wrong reasoningEditor
Layer 3: HarnessArming a single run (tools/actions)One taskA bad diff caught before shippingReviewer
Layer 4: LoopScheduling the harnessUnattended iterationsStructural rot that creeps in over daysArchitect

Anatomy of a Loop That Keeps Running

An autonomous loop consists of five nodes.

  1. Discovery — backed by Skills (SKILL.md). This is the project's permanent knowledge, and it pays down "intent debt."

  2. Handoff — backed by Worktrees: independent git directories for parallel execution.

  3. Verification — backed by sub-agents. The Generator–Evaluator separation: "something that can say no."

  4. Persistence — backed by connectors (MCP) and memory. State lives in files on disk (such as ./state/triage.md). The agent forgets; the repository doesn't.

  5. Scheduling — backed by automation infrastructure (local cron, GitHub Actions, cloud routines). This is what closes the cycle.

Worktree Parallelization

The problem: Two agents editing the same working directory is like two engineers committing to the same line. Collisions break an unattended pipeline. The primitive: Isolate independent working directories, as in claude --worktree fix/auth-test 'draft the fix'. The effect: Parallelization goes from "works, but messy" to "works, and clean." Multiple independent working directories within a single repository make high-throughput issue triage possible.

The Self-Persuasion Bubble — Separating Generator and Evaluator

The anti-pattern is letting the Generator grade its own homework. The Generator isn't really looking at its code; it's looking at its own chain of self-persuasion. The GAN split, by contrast, separates the Generator from the Evaluator and casts the Evaluator as an adversarial code reviewer: "Assume this code is broken until proven otherwise. Do not praise it. Find where it fails."

The core insight: Tuning an independent evaluator to be a rigorous skeptic is far more achievable — both mathematically and in practice — than getting a generator to be critical of its own work.

Verdicts Through External Execution

The flaw: If the Evaluator only reads the code, its verdict is "does this look correct?" rather than "does this actually work?" The shift: Connect the Evaluator to an external execution environment (e.g., Playwright MCP). The new standard: The Evaluator clicks buttons, forces screen transitions, captures DOM state, and runs tests. The verdict moves from "intent" to "behavior." The flow becomes: Evaluator agent → Playwright MCP connector → DOM inspection / screenshots / test runner → pass/fail verdict.

Maker-Checker Stop Conditions

When should a loop end? The /goal primitive expresses "keep going until the condition is met" (for example: /goal all tests in test/auth pass and lint is clean). The Generator (a heavyweight model) writes code, the Evaluator (a heavyweight model) runs tests via MCP, and the Gatekeeper (a fast, fresh model) evaluates the /goal. If it's satisfied, the loop exits; if it fails, the rejection reasons are sent back to the Generator.

The principle: The decision that work is complete must be made by a fresh model carrying none of the contextual baggage of the model that did the work. And there's a maxim worth remembering: The floor of the loop is the evaluator. The generator sets the ceiling on what gets produced; the evaluator sets the floor on what doesn't.

Five Ways a Loop Fails

Missing elementAnti-patternSymptomRequired fix
No verificationThe nodding loop100 turns of approving its own garbageImplement the Generator–Evaluator separation
No persistenceThe amnesiac loopRediscovers exactly the same work every morningForce state files to be written to disk
No schedulingThe manual loopHasn't run once since the day it was demoedWire up cron/event triggers
No discoveryThe blind loopStill spending 30 minutes pasting "fix this bug" every single timeBake the heuristics into SKILL.md
No handoffThe tangled loopFive parallel agents wrecking a single git directoryEnforce isolation with --worktree

Deterministic Interleaving at Enterprise Scale

Stripe's "Minions" pipeline runs as follows: trigger (Slack) → context orchestrator (Sourcegraph/Jira) → code generation (LLM) → mandatory linter gate → lint fixes (LLM) → git commit → human review (1,300 PRs/week). The result: 1,300 machine-generated PRs merged every week (powered by the open-source framework Goose).

The secret is letting deterministic systems do deterministic work. Context gathering and linting are strictly hard-coded, and the LLM is fully confined within guardrails bound by rigid rules. Environments are treated as "cattle, not pets": Devboxes on EC2 are swapped out and destroyed immediately to avoid state rot.

Execution Topologies — Where Does the Loop Live?

TopologyMachine stateSessionMinimum intervalLocal filesystem access
Cloud (Cloud Routines / GitHub Actions)Works even with the machine offNot required1 hourNone (clean clone) → best for overnight triage
Desktop (macOS cron)Machine onNot required1 minuteYes → best for periodic repository maintenance
Local (/loop command)Machine onRequired1 minuteYes → best for high-frequency checks during development

Calling a local re-run "running while you sleep" is an exaggeration. Local scheduling buys you frequency; cloud scheduling buys you true autonomy. No single scheduler gives you both.

The Vicious Cycle of the Unwatched Loop

An unattended loop carries four risks. Verification debt (merging code that passes its tests but harbors subtle logic flaws) → comprehension rot (your mental map of the codebase drifts away from reality) → cognitive surrender ("I don't know how this works, but let's accept the PR") → token burn (an unwatched agent spawning helpers all night, endlessly retrying futile bug fixes). These aren't four separate risks; they are a single, compounding failure mode. A loop without a rigorous evaluator has delegated its spending decisions to its own bugs.

The Economics of Zero-Cost Generation

What becomes abundant: generation. The cost of code, plans, fixes, and pull requests heads toward zero, and mechanical labor collapses. What stays scarce: judgment. A loop can generate 100 candidate implementations, but its choice among them is based on "looks correct," not "is actually correct." The loop as amplifier: a loop is a faithful multiplication sign. Bring in understanding and it amplifies understanding; bring in laziness and it amplifies disaster.

Operational Circuit Breakers

  1. Always read a sample (defense against comprehension rot): Every day, pick a machine-generated PR at random and check whether you can explain it in your own words. If you can't, your mental map is already stale.

  2. Set caps before you ship (defense against token burn): Per-run budget ceilings and maximum retry counts aren't about saving money; they are circuit breakers that convert open-ended risk into bounded risk.

  3. Leave one door open (defense against cognitive surrender): Build at least one checkpoint where the loop pauses for a human — not so you intervene every time, but to guarantee that you can.

Deploying the Minimal Resilient Loop

The minimal configuration looks like this. A schedule (cron: cloud automation) kicks things off; a skill (morning-triage: discovery) runs; and the results are written to ./state/triage.md (persistence). Any fixes that are discovered are carried out in a worktree (fix/$finding: handoff) and judged against a /goal (verification) of "tests pass and lint is clean." Output is split across three folders—./inbox/ (everything not yet verified), ./state/, and ./src/—and the governing principle is this: never auto-merge. Anything unverified lands in ./inbox/.

Let me close with this.

"Build the loop. But build it as someone who intends to remain an engineer—not as someone who just presses the button."

The end

Read next ↓

Share this research