Deep dive 1 of 5: the loop
One agent, one job, run until the result checks out.
The short version
An agent is a prompt, a model and tools, running in a loop until a job is done.
In the example, someone asks an agent to fix a broken link. Its first edit has a typo. A test catches it, it goes round again, and the test passes. A person gets the fixed page and the evidence. Two more jobs show the other endings: one hits its limit on tries, and one stops to ask a person.
The five steps, in words
- Prompt
- The input. The job in plain words, and any rules for doing it.
- Model
- The part that reads and decides. On its own, it can only write.
- Tools
- What it acts with, such as reading a file or running a test.
- Loop
- The model picks a tool, the tool runs, and the result goes back. This repeats until a check passes, a limit is hit, or it needs a person.
- Output
- The result and the evidence for it, handed to a person.
Two loops, three exits
The example above shows one loop. In practice there are two, one inside the other, and each has its own cap. Spotify reported 10 turns per session and 3 session retries for its first version (2025-11).
Around the run the harness
Inside a run the agent
The agent repeats until it stops calling tools or hits the turn cap.
The harness runs the done check and may start another run, up to the retry cap.
In this model, every exit ends the same way: a draft plus evidence goes to a named person. Not every company works like this. StrongDM, in the table below, states that people neither write nor review the code.
The loop is the cheap part
Anthropic's definition: "LLMs using tools based on environmental feedback in a loop" (2024). The loop itself is cheap: Thorsten Ball builds one in under 400 lines of Go (2025-04). The leverage is in the tools, the context and the check.
How other companies do it
Most accounts end in a PR for a person, and StrongDM does not. Who decides done varies: a fixed gate, a second model or the worker itself. Five of the ten below publish a numeric cap.
All company-reported, and we saw no published defect rates. Anthropic, OpenAI, Vercel and Factory also sell what they describe.
| Company | The loop | The check | The limit | The person |
|---|---|---|---|---|
| StripeMinions, 2026-02 | Blueprint mixes fixed steps (lint, push) with agent steps | Local lint, then CI | Retries: 1 send-back (2 CI rounds), then back to the engineer | Reviews before merge |
| SpotifyHonk, 2025-12 | Agent calls a verify tool. A stop hook runs all verifiers before a PR can open. | Verifiers chosen by repo contents, plus a judge comparing diff to prompt | Turns: 10 per session, 3 session retries, in the first version. Current cap not published. | Owning team merges |
| VercelAI SDK factory, 2026-08 | Triage, analysis, build and review stations, each in its own sandbox | A probe that fails before the fix | Retries: its template allows 2 revision cycles, then halts with no PR | A person approves every merge |
| AnthropicClaude Code, docs | Gather, act, verify. Ends when a response has no tool calls. | Tests, stop hooks, a fresh reviewer session | None by default. Docs advise starting over after 2 failed corrections. | Docs ask who signs off before an unattended run |
| StrongDMThe counterexample, 2026-02 | Agents write and test until scenarios converge | Holdout scenarios the builder cannot see, with a satisfaction score | Until scenarios pass. No number published. | States that people neither write nor review the code |
Five more companies, and further reading
| Company | The loop | The check | The limit | The person |
|---|---|---|---|---|
| EveryCompound engineering, 2025-12 | Plan, work, review, compound. Lessons go to files later runs read. | Parallel review agents, browser tests | Retries: 3 CI fix attempts, then it lists what failed | Plans and reviews, about 80% of feature-building effort |
| OpenAICodex, Symphony, 2026 | Agent builds, reviews its own change, asks other agents to review, and iterates | Tests, builds, browser driving, logs, custom linters | Turns: Symphony runs 20 per invocation and restarts on stall | Not confirmed. A separate OpenAI post on Symphony says people review results. |
| ShopifyRiver, 2026-05 | Builds, tests, runs simulators, opens a PR. On failure, reads logs and retries. | Tests, simulators, screenshots | No number published. Security flow ends fixed, rejected or escalated. | Code owners review and merge |
| RampInspect, undated. From earlier repo notes; our search saw only the intro. | A full dev VM. Pushes a branch and opens a PR. | Tests, telemetry, flags, screenshots | Not published | Requester's token opens the PR, and a colleague can take over |
| FactoryMissions, undated | Writes testable assertions first, then a worker per feature in a clean session | Fresh validators at each milestone, separate from the builders | Ends when validation passes. Retry default not found. | Plans up front. Merge role not detailed. |
- Airbnb: 97% of about 3,500 test files, a state machine with per-step retries (date not established).
- Google: migrations with fixed search, model edits and build-test-repair (2025-01).
- Cursor: planners and workers at large scale (2026-01).
- Anthropic's C compiler run: a bash loop, 16 agents, about USD 20,000, a research prototype (2026-02).
- Linear Loops: a trigger wrapper; our search found no documented check (2026-07).
- GitHub's coding agent: 59 minutes maximum on Actions-based sessions (as of 2026-10-30).
Frameworks we can use
They all have a loop. They differ on who approves mid-run, what survives a crash, and whether you are locked to one model vendor.
Of the framework docs, only Anthropic's and GitHub's were on our fetch allowlist. Other rows come from search summaries of official docs, so check option names before use. Default caps use different units, and licenses were not confirmed. Claude, made by Anthropic, drafted this page.
| Name | Run the loop with | What stops it | A person approves with | If the process dies | Model lock |
|---|---|---|---|---|---|
| Claude Codeheadless | claude -p, /goal, Stop hooks | --max-turns (no limit by default), --max-budget-usd | --permission-prompt-tool. Otherwise calls needing approval are denied. | --resume. You restart it. | Claude models, direct or through a cloud provider. See its terms. |
| OpenCodeopen-source CLI, as of 2026-11-01 | opencode run | steps per agent. No limit by default, per the v1 docs. In v2 the last step removes tools and asks for a summary. | Permission rules: allow, ask or deny. --auto approves all but explicit denials. The docs do not say what run does on ask. | --session or --continue. Automatic restart not confirmed. | None seen. 75+ providers and local models. |
| Claude Agent SDKinside your own program | query() | max_turns, max_budget_usd. No limit by default. | canUseTool | You resume it with the session id. | Claude models |
| Pydantic AIPython library | Agent.run(), agent.iter() | UsageLimits, default 50 requests, with a cost limit | DeferredToolRequests, with no live process | Temporal, DBOS or Prefect | None seen |
| LangGraphthe flow as a graph | A graph, or create_agent | recursion_limit, default 10,007 steps from library 1.1.4 (10,011 on Agent Server). Call-limit middleware. | interrupt() | Checkpoints. The node reruns from its start. | None seen |
| Temporala durable layer under any loop | Your loop in a Workflow | Your code, plus framework caps | An Update, or a Signal per the TypeScript docs. Waits survive restarts. | Replays history and continues | None. You run or buy it. |
| Ralpha technique, not a framework | A bash loop feeding one prompt to any CLI agent | An optional iteration count in the reference script (no cap if omitted), or Ctrl+C | None in the loop | Loses one pass. State is in files and git. | None |
Twelve more frameworks
| Name | Run the loop with | What stops it | A person approves with | If the process dies | Model lock |
|---|---|---|---|---|---|
| CodexCLI | codex exec, /goal | Goal token budget, in the App Server API only. A max-turns flag was not established. | --ask-for-approval. In codex exec, an action needing new approval fails rather than waits. | codex exec resume | Model default not confirmed |
| goose | goose run with recipes | GOOSE_MAX_TURNS, default 1000. Recipe retries and checks. | GOOSE_MODE. Cannot ask when headless. | goose session --resume | None seen |
| Pi | agentLoop, agent.prompt() | No cap in core. beforeToolCall can end the run. | Build your own | JSONL sessions. Durable package is experimental. | None seen |
| OpenAI Agents SDK | Runner.run | max_turns. Reference pages show 10. | needs_approval, then resume from RunState | Saved RunState. Temporal integration. | Soft |
| Vercel AI SDK | ToolLoopAgent, generateText | stopWhen. Default 20 steps for ToolLoopAgent. | toolApproval. WorkflowAgent uses needsApproval. | Lost in memory. WorkflowAgent survives. | None seen |
| Mastra | Agent.generate() | maxSteps, default 5. stopWhen. | requireToolApproval | Workflow snapshots, Inngest agent | None seen |
| smolagents | agent.run(), agent.step() | max_steps, default 20. final_answer_checks. | No approval option found | Not established | None seen |
| Google ADK | Runner. LoopAgent is giving way to Workflow. | max_iterations, max_llm_calls default 500 | require_confirmation | ResumabilityConfig, in Python and Kotlin docs | Agent Config docs say Gemini only |
| Microsoft Agent Framework | Agent, AgentLoopMiddleware | AgentLoopMiddleware default 10 runs. Tool roundtrips default 40. | always_require on a tool | Workflow checkpoints, durable agents | None seen |
| CrewAI | Agent inside a Crew | max_iter, default 20 or 25 (its docs disagree) | human_input, @human_feedback | @persist on a Flow | None seen |
| Inngest | step.run() in a plain loop | Your loop bound, or AgentKit maxIter | step.waitForEvent() | Saved steps. | None seen |
| Cloudflare Agents | Agent on a Durable Object | maxSteps, default 10 in Think | needsApproval, waitForApproval() | runFiber recovery | Workers AI, OpenAI and Anthropic bindings listed. Runs on Workers. |
Not covered, because their docs could not be read here: Aider, Cline, Gemini CLI, Strands Agents, LlamaIndex, Letta and AutoGen. Read in part: GitHub Copilot SDK and OpenHands SDK. Many teams skip frameworks: 17 of 20 case studies built custom loops on direct API calls, though 61% of survey respondents used a framework (2025-12).
All links
The articles that matter, by topic. All 437 sources from the research are listed in standard/.
- Fetched for this page, some abstract only
- Read in the repo's earlier research
- Confirmed by search, not opened
Start here
- Building effective agents, Anthropic, 2024-12
- Building agents with the Claude Agent SDK, Anthropic, 2025-09
- Getting started with loops, Anthropic, 2026-06
- Designing agentic loops, Simon Willison, 2025-09
- Software Factories, Light and Dark, Addy Osmani, 2026-07
Foundations and research (10)
- ReAct, Yao et al., 2022
- Reflexion, Shinn et al., 2023
- Large language models cannot self-correct reasoning yet, 2023
- Agentless, the no-loop control, 2024
- Magentic-One, stall counters, 2024
- Measuring Agents in Production, 2025
- Loop Engineering: Building Blocks, Adoption, and Impact, 2026
- LoopsBench, 2026
- When Do Agent Loops Mistake Stagnation for Progress?, 2026
- More with Less: turn-control strategies, 2025
Practitioners (13)
- Ralph Wiggum as a "software engineer", Geoffrey Huntley, 2025-07
- Everything is a Ralph loop, Geoffrey Huntley, 2026-01
- How to Build an Agent, Thorsten Ball, 2025-04
- 12-factor agents, Dex Horthy
- Advanced context engineering for coding agents, Dex Horthy, 2025
- A brief history of Ralph, HumanLayer, 2026-01
- Long context isn't the answer, HumanLayer, 2026-03
- Don't waste your back pressure, Moss Ebeling, 2026-01
- The coming loop, Armin Ronacher, 2026-06
- Loop Engineering, Addy Osmani, 2026-06
- Practical Loop Engineering, Addy Osmani, 2026-08
- Default hard budget caps, Simon Willison, 2026-10
- Context engineering lessons from Manus, 2025-07
Anthropic: long runs and docs (12)
- Effective harnesses for long-running agents, 2025-11
- Harness design for long-running apps, 2026-03
- Building a C compiler with parallel Claudes, 2026-02
- Effective context engineering, 2025-09
- Claude Code auto mode, 2026-03
- Measuring AI agent autonomy in practice, 2026-02
- How Claude Code works, docs
- How the agent loop works, docs
- Best practices for Claude Code, docs
- Keep Claude working toward a goal, docs
- Run Claude Code programmatically, docs
- Automate actions with hooks, docs
OpenAI (6)
Company accounts (18)
- Stripe Minions, part 1, 2026-02
- Stripe Minions, part 2, 2026-02
- Spotify Honk, part 1, 2025-11
- Spotify Honk, part 2, 2025-11
- Spotify Honk, part 3: feedback loops, 2025-12
- Ramp: why we built our own background agent
- Shopify: under the River, 2026-05
- Shopify: River security work, 2026-09
- Vercel: a software factory for AI SDK, 2026-08
- Vercel: build a software factory with eve
- Every: compound engineering, 2025-12
- Cursor: scaling long-running autonomous coding, 2026-01
- Cognition: closing the agent loop, 2026
- Factory: how Missions work
- StrongDM: Software Factory, 2026-02
- Linear: introducing Loops, 2026-07
- Airbnb: large-scale test migration
- Google: AI for internal code migrations, 2025-01
Evidence on limits and failure (15)
- METR: task time horizons
- METR: Frontier Risk Report, 2026-05
- METR: many passing PRs would not be merged, 2026-03
- METR: Claude Code and Codex against default scaffolds, 2026-02
- METR: recent models are reward hacking, 2025-06
- METR: early-2025 developer study, 2025-07
- METR: changing the productivity experiment, 2026-02
- ImpossibleBench, 2025
- How coding agents fail their users, 2026
- Overclaiming in frontier agents, 2026
- All Smoke, No Alarm: test oracles, 2026
- When Agents Do Not Stop, 2026
- Compact-Bench, 2026
- SlopCodeBench, 2026
- The Attacker Moves Second, 2025
Beyond code, and regulated work (8)
Framework docs are linked in the framework tables.