H
Howardism
Plate IIAgent Systems中文HOWARDISM

Agent Loop Pattern

PublishedMay 6, 2026FiledConceptDomainAgent SystemsTagsAgent EngineeringHarnessAutomationReading8 minSourceAI-synthesised

`/loop` (cron-scheduled) and Ralph Wiggum (backlog-draining) loops as next-generation agent primitive; AFK execution, parallel fan-out, "loops are the future"

Illustration for Agent Loop Pattern

Sources#

Summary#

A loop is an agent process that repeatedly executes a prompt until a queue is empty or a stopping condition is reached. As of mid-2026, three converging implementations point to the loop becoming a primitive on par with the single-shot session: Anthropic's /loop slash command (cron-scheduled, repeating), Anthropic's routines (server-side /loop), and Matt Pocock's Ralph Wiggum loop (bash + claude --permission-mode accept-edits in a while). Boris Cherny calls loops "the future"; Matt Pocock uses them as the AFK backbone of his end-to-end workflow.

The two loop families#

Cron-scheduled loops (/loop, routines)#

Used inside Claude Code and Cowork. Mechanism: agent calls cron (via tool) to schedule a job at a future time; the job re-enters the agent at that time with an instruction to perform the task. The schedule can repeat (every minute, every 5 minutes, every day).

Boris Cherny's reported uses:

  • Babysit PRs — fix CI, auto-rebase
  • Keep CI healthy — heal flaky tests
  • Cluster Twitter feedback every 30 minutes
  • "Dozens of loops running at any time"
  • Overnight: "a few thousand agents" doing deeper work

Routines are the same primitive on the server, so they survive the laptop being closed.

Backlog-draining loops (Ralph Wiggum loop)#

Used by Matt Pocock and others. Mechanism: a shell script runs the agent on a fixed prompt, the prompt instructs it to pick the next task from a backlog and complete it, the script restarts. The backlog is a directory of markdown issue files (or GitHub issues).

Pocock's once.sh skeleton:

issues=$(cat issues/*.md)
recent_commits=$(git log -5 --oneline)
prompt=$(cat prompt.md)
claude --permission-mode accept-edits "$prompt" --context "$issues" "$recent_commits"

The "loop" wrapper just re-runs once.sh until the agent emits a sentinel (no more tasks) or the harness stops it.

The prompt enforces AFK-only task selection — only tasks tagged AFK (vs human-in-loop) are eligible.

Why loops matter#

  1. Amortize planning over many executions. One careful planning session (e.g. via Design Concept Grilling) creates a Kanban backlog (see Vertical Slice Tracer Bullets); loops drain it without further human input.
  2. Hours-long tasks become tractable. Rather than one giant context window, the loop fragments work into many fresh sessions — staying in the Context Window Smart Zone each time.
  3. Parallelization. Independent backlog items run on separate sandboxes simultaneously. Pocock's Sandcastle library does this with per-issue git worktrees in Docker containers; merger agent reconciles afterwards.
  4. Idle compute. Boris's overnight setup is a thousand-agent loop on cheap idle hours — work that wouldn't be worth a human's evening but produces value at agent cost.

AFK vs human-in-loop tasks#

Matt Pocock's key distinction:

  • AFK tasks — implementation, refactoring, test scaffolding, doc gardening, CI healing. The agent can succeed without per-step approval; verification is automatic (tests, types, linters).
  • Human-in-loop tasks — alignment, design choices, prioritization, QA. These have no mechanical verification; they need taste and tacit context.

Loops are for the AFK class. Trying to loop human-in-loop work produces drift — the agent makes plausible-but-wrong calls and accumulates them.

Verification is the ceiling#

Pocock's stronger claim: the quality of feedback loops sets the ceiling on what loops can do. Without good tests, types, and linters, the loop is "coding blind." This is the same point made in Agent Harness Engineering about mechanical enforcement — loops just expose the cost more starkly because there's no human to catch drift.

Connection to model trajectory#

Boris Cherny reports that Opus 4.7 spontaneously starts loops without prompting:

"I'll tell it, 'Go pull this data query.' And it's like, 'Hey, I noticed that the data is changing over time. I'll start a loop and I'll give you a report every 30 minutes.'"

This fits Harness Shrinkage as Models Improve — capability the harness used to inject becomes natural model behavior. The loop primitive remains, but the user no longer has to invoke it.

Connections#

  • Claude Code Best Practices — the best-practices guide treats /loop as a core workflow primitive
  • Engineer PM Convergence — generalist PM-engineers fan work out across loops
  • Boris Cherny — primary advocate, day-to-day driver
  • Matt Pocock — Ralph loop + Sandcastle exemplar
  • Harness Shrinkage as Models Improve — loops as next-generation primitive replacing per-step prompting
  • Context Window Smart Zone — why fragmenting into many fresh sessions beats one long one
  • Vertical Slice Tracer Bullets — what fills the backlog the loop drains
  • Design Concept Grilling — the planning step that justifies the loop
  • Deep Modules for Agents — modules with strong test boundaries make loops viable
  • Agent Harness Engineering — generalizes the "verification is the ceiling" point
  • Symphony — daemon-driven equivalent at the orchestration layer
  • Claude Code Auto Mode — permission classifier that lets accept-edits mode be safe in AFK loops
  • Agentic Misalignment (AM) — loops + weak per-action oversight is exactly the AM threat surface; loop reviewers depend on model-side alignment holding up unattended
  • AI Brain Fry — the human-side limit on output multipliers: more loop output → more review → more cognitive fatigue → more missed errors
  • Human-AI Accountability Redesign — loops force the redesign question; span-of-control redesign is the missing partner for unattended loop deployments
  • AI-Driven Formal Proof Search — DeepMind's basic proof-search agent is literally a "Ralph loop" (huntley2025ralph): episodes of generate→compile→learn-lessons, run as parallel independent subagents
  • AlphaProof Nexus — the framework whose basic agent (A) is a Ralph-loop fleet; it matched the bespoke system on most problems
  • Agent-Native Infrastructure — always-on loops acting via sensors/actuators are the runtime of Karpathy's agent-native world
  • Stopping Under a Noisy Verifier — the measured case against this primitive's two default stop conditions. A round cap ("repair up to K times") is the worst deployable arm in Wu et al.'s stress setting — 0.116 true validity against 0.700 for committing the first draft, degrading monotonically with the budget — and a sentinel the agent emits is only as good as the verifier behind it, whose discrimination bounds how fine a stopping decision it can support. The transferable rule: the stop boundary belongs to whatever rewrites the work, not to whatever checks it, so it is α/(α+β) and ports between loops no better than those two rates do
  • Loop Engineering — the system-design discipline one floor above this primitive (Osmani / Steinberger): automations are the loop's scheduled heartbeat, and /goal (keep going until a written condition holds, with a separate small model checking "done" after each turn) is the maker/checker split applied to the stop condition itself
  • The Three Loops of AI-Native BuildingAndrew Ng's taxonomy places this primitive: it closes the innermost of three nested loops, and the developer-feedback and external-feedback loops outside it run 1–2 orders of magnitude slower
  • Dynamic Workflows: An Algebra for Agents — the sibling primitive for one large task rather than a repeating one: a workflow structures a single run across staged agents, where this page's loop asks "when does it run again?"

Open Questions#

  • When the model schedules its own loops (4.7 behavior), who owns the budget? Boris answered "the model just decides" — but that pushes cost discipline into the model's training, not the harness.
  • Does a loop with a smart enough model still need a Kanban backlog, or does the model choose its own next task from raw goals?
  • Loop output review is now Matt Pocock's confessed bottleneck — "we just need to be ready to be doing more code review."

Sources#

§ end
About this piece

Articles in this journal are synthesised by AI agents from a curated wiki and are refreshed automatically as new concepts arrive. Topics, framing, and editorial direction are curated by Howardism.

Cited by 31
Related articles
  • Agent Harness Engineering

    Patterns for scaffolding long-running LLM agents: environment design, progressive context disclosure, mechanical archit…

  • Harness Shrinkage as Models Improve

    Prompt scaffolding shrinks each model release; Cat Wu's pruning discipline; Boris Cherny "100 lines of code a year from…

  • Claude Code

    Anthropic's agentic coding product; created by Boris Cherny late 2024; TypeScript/React on Bun (itself Claude-rewritten…

  • Loop Engineering

    Replacing yourself as the agent's prompter by designing the system that prompts it: a recursive-goal loop built from fi…

  • Verification as the New Bottleneck

    Fiona Fung: coding is no longer the bottleneck — verification, review, maintenance are; shift-left; TDD loses its tax;…