← Back to Blog

Loop Engineering: The New Meta for AI Agents

On June 7, 2026, three engineers from three different companies said the same thing within 48 hours of each other — and the AI dev community hasn't stopped talking about it since. Boris Cherny (head of Claude Code at Anthropic): "I don't prompt Claude anymore. I have loops running that prompt Claude and figuring out what to do. My job is to write loops." Peter Steinberger (OpenAI): "You shouldn't be prompting coding agents anymore. You should be designing loops that prompt your agents." Addy Osmani (Google): named and structured the practice in a widely shared essay calling it Loop Engineering.

The term crystallised a shift that had been building for two years. But to understand why loop engineering matters — and how to actually do it — you first need to understand what happens inside the loop itself.

When you ask Claude to write and debug a Python script, it doesn't just respond once and stop. It writes code, notices a potential issue in its own output, revises, considers edge cases, revises again — all before you see a single character. That internal rhythm — observe, think, act, observe again — is the agentic loop, and it's the core engine behind every modern AI agent. Loop engineering is the discipline of designing that engine, not just riding it.

The Loop, Visualised

👁️ PERCEIVE
🧠 THINK
⚡ ACT
🔍 OBSERVE
Agent
Loop

One loop iteration ≈ one "thought step"

The spinning arc shows the agent's current focus rotating through each stage. In Claude, this loop can run dozens of times per response during extended thinking — each turn tightening the output toward the correct answer.

The loop terminates when a stopping condition is met: task complete, token budget reached, or the agent decides no further action improves the answer.

The Four Phases in Detail

👁️
Phase 1
Perceive
The agent receives its full context: your prompt, any prior conversation, results from the last tool call, system instructions, and memory state. This is the "inbox" before any thinking begins. In Claude, this is the entire context window at the start of each generation step.
🧠
Phase 2
Think / Plan
The agent reasons over its context. This is where chain-of-thought happens. In Claude's extended thinking mode, this is explicit — you can see the internal scratchpad. The model decomposes the task, identifies what information is missing, and selects an action. Good thinking here prevents wasted action steps later.
⚡
Phase 3
Act
The agent executes: calls a tool (web search, code interpreter, file read), generates a draft response, writes to memory, or calls another agent. In Claude Code, Act is when a shell command runs or a file gets edited. One act per loop iteration — this keeps actions auditable and reversible.
🔍
Phase 4
Observe
The result of the action flows back into context. A tool returned an error? That error is now the top of the context window heading into the next loop. This is the self-correcting mechanism — the agent sees what it did, evaluates the outcome, and either loops again or terminates. Most bugs in agent pipelines live here: truncated outputs, silent errors that look like success.
The loop isn't a limitation — it's the feature. A single-shot LLM response is a guess. A looping agent is an iterative solver. The difference in output quality grows exponentially with task complexity.

Try It in Claude: 3 Real Examples

Each example below is designed to deliberately trigger the agentic loop. You'll see Claude self-correct mid-response, revise its plan, or acknowledge an assumption was wrong. That's the loop working.

⚡ Example 1 — Code Debugging Loop
Trigger: "Write code, run it, fix what breaks"
You → Claude: Write a Python function that reads a CSV file, finds duplicate rows based on email column, and returns a deduplicated dataframe. Then walk through what would happen if the CSV has: 1. An email column with mixed case (e.g. "User@Gmail.com" vs "user@gmail.com") 2. Rows where the email field is empty 3. A file path that doesn't exist For each case, show what your current code does wrong, then fix it and explain what changed.
🔁 Loop trigger: Asking Claude to deliberately find its own bugs forces multiple Perceive→Think→Act→Observe cycles. Watch how it revises the function 3 times — one per edge case.
⚡ Example 2 — Research Synthesis Loop
Trigger: "Build an argument, then steelman the opposite"
You → Claude: Topic: "LLMs will replace most knowledge workers within 5 years." Step 1: Build the strongest possible case FOR this claim. Use specific evidence, name companies, cite trends. Step 2: Now act as a skeptic. Find the 3 weakest points in your own Step 1 argument. Be specific about what evidence you overstated or what you assumed without proof. Step 3: Revise your original claim to a version you'd actually defend in front of economists.
🔁 Loop trigger: Step 2 forces Claude to observe its own output from Step 1 and critique it. This is a manually structured agentic loop — you're the orchestrator running the Observe phase explicitly.
⚡ Example 3 — Planning + Self-Correction Loop
Trigger: "Plan a task, then catch your own planning errors"
You → Claude: I want to launch a newsletter about AI for non-technical founders. I have zero subscribers, $0 budget, and 5 hours/week. First: give me a 90-day launch plan. Then: review your own plan and identify every assumption you made that could be wrong. For each assumption, tell me what happens to the plan if that assumption fails — and what the backup is. Finally: give me the single most important action for Day 1 that doesn't depend on any of those assumptions being true.
🔁 Loop trigger: The "review your own plan" step forces a full Observe cycle on Claude's own output. The final step forces synthesis after self-correction — this is three loop iterations in a single prompt.

Where the Loop Changes the Game

The loop isn't equally valuable everywhere. Here are the scenarios where it earns its keep:

🔧
Complex Software Development
Writing a function that calls an API, parses the response, handles rate limits, and retries on failure. Each of those requirements is one loop iteration. A single-shot response to "write this API caller" misses 3 of 4 requirements on average.
Write draft Find missing error handling Add retry logic Test edge cases
📊
Data Analysis with Unknown Structure
When you don't know what's in a dataset before you start, the loop is essential — inspect the data, form a hypothesis, test it, revise. In Claude's code interpreter, this is the natural rhythm of exploratory analysis.
Inspect schema Identify anomalies Adjust analysis
✍️
Long-form Writing and Editing
First draft → identify weak sections → rewrite them → check for consistency → polish tone. Each step is a loop. The quality gap between "write me an article" and a looped write-critique-revise cycle is dramatic on any piece over 500 words.
Draft Self-critique Targeted revision
🤔
Strategic Decision Analysis
Build a case, find the weakest assumptions, pressure-test with adversarial scenarios, arrive at a robust conclusion. This is the loop applied to thinking — and it's where Claude's extended thinking model especially shines over single-pass responses.
Initial analysis Stress test Revised recommendation

Is This Universal? How Competitors Use the Loop

Yes — the agentic loop is the standard pattern across all frontier AI systems. The differences are in implementation details: how many iterations, how tools are called, how memory is managed.

System Loop Mechanism Tool Use Self-Correction
Claude (Anthropic) Extended thinking + tool_use content blocks Full Native in CoT
GPT-4o / o3 (OpenAI) Reasoning tokens (o-series) + function calling Full Native in o-series
Gemini 2.0 (Google) Native function calling + Gemini Live streaming Full Partial
LangGraph / LangChain Explicit graph nodes — loop is in the framework Full Framework-level
Cognition Devin Long-horizon agent loop with shell + browser Full Core design
Microsoft Copilot Orchestration layer over GPT-4 + Bing Search + Office Limited

The strategic differentiator isn't whether a system has the loop — they all do. It's loop depth (how many iterations before output), loop transparency (can the user see the reasoning?), and loop cost (compute per iteration). Claude's extended thinking makes the loop unusually transparent; o3's deep reasoning makes it unusually deep.

Loop Engineering: The New Meta

On June 7, 2026, a handful of engineers from Anthropic, OpenAI, and Google converged on an idea that had been forming for months: the bottleneck had shifted. Getting a model to produce one great output was a solved problem. The hard part was now designing the system that prompts the agent — automatically, reliably, at scale. They called this new discipline Loop Engineering.

⚡ JUNE 7, 2026 — THREE PERSPECTIVES
BC
"Loop Engineering is what happens when prompt engineering grows up. You stop writing prompts and start writing systems that write prompts. The agent becomes an output of your architecture, not the other way around."
Boris Cherny — Anthropic
PS
"We've been thinking about this wrong. The loop isn't something the model does — it's something you design. When you design the loop well, the model's raw capability stops being the limiting factor."
Peter Steinberger — OpenAI
AO
"The developers who will matter most in the next five years aren't the ones who write the best prompts. They're the ones who architect the best loops — verifiers, handoffs, memory schemas, stopping conditions."
Addy Osmani — Google
Prompt Engineering
The old meta (2022–2025)
  • One input → one output
  • You craft the perfect ask upfront
  • All complexity lives in the prompt
  • Model corrects nothing — you retry manually
  • Skill: precise, structured instructions
  • Ceiling: one context pass
  • You are the orchestrator
Loop Engineering
The new meta (2026 →)
  • Designing systems that prompt agents automatically
  • You architect the process, not just the ask
  • Complexity distributed across loop iterations
  • Agent self-corrects; verifier checks the result
  • Skill: orchestration, verifiers, stopping conditions
  • Ceiling: compute and loop depth only
  • The loop is the orchestrator

The Five Building Blocks of a Loop

Every well-engineered loop is assembled from five primitives. Master these and you can compose arbitrarily complex agent systems from simple, auditable parts.

⚙️
Automations
Scheduled triggers that kick off loops
Event-driven or time-driven conditions that launch the agent without human input. The loop doesn't wait for you to press "run."
→ "Every morning at 9am, pull yesterday's GitHub issues and triage them."
🌿
Worktrees
Isolated execution contexts
Each loop instance runs in its own sandboxed environment — a separate git worktree, container, or filesystem snapshot. Parallel loops don't collide.
→ "Run five candidate fixes in parallel worktrees; pick the one that passes all tests."
🎯
Skills
Reusable agent capabilities
Named, composable capabilities the agent can invoke — like calling a function. Skills abstract complexity and make loops auditable. In Claude Code these are slash commands.
→ /review, /deploy, /summarize — each a skill the loop can chain.
🔌
Plugins / Connectors
Tools that extend the agent's reach
MCP servers, APIs, browser tools, database connectors. Plugins let the loop read and write the external world. Without them, the agent is reasoning in a vacuum.
→ GitHub MCP, Jira connector, Slack webhook, SQL read tool.
🤝
Sub-agents
Delegated parallel execution
The orchestrator loop can spin up sub-agents for parallelizable work — each running their own inner loop. Results flow back up for synthesis or verification.
→ Orchestrator delegates test writing, documentation, and code review to three parallel sub-agents.
🧠
Memory
State that persists across loops
Without memory, each loop iteration starts cold. Structured memory — files, vector stores, key-value caches — lets the agent build on prior runs instead of rediscovering everything.
→ CLAUDE.md project instructions, embeddings of past decisions, structured task logs.

The Verifier: The Most Underrated Component

Every loop needs two roles: a doer and a checker. The doer executes. The checker decides whether the execution was good enough to stop. Without a well-designed verifier, loops either run forever or terminate too early. The verifier is where most loop engineering happens in practice.

✅ Good stopping conditions
  • All tests pass with zero failures
  • Output matches a formal specification (JSON schema, regex, etc.)
  • A second model instance independently agrees with the result
  • Human-in-the-loop approval before merge
  • Explicit task completion signal from the environment (CI green)
❌ Bad stopping conditions
  • "The model says it's done" — self-reported success is unreliable
  • Fixed iteration count ("run 10 times") — loops should be outcome-driven
  • No stopping condition — runaway loops burn tokens and money
  • Silent success — errors that look like success (empty output, no exception)
  • Only checking the final step — errors propagate from early iterations

Claude Code: Native Loop Commands

Claude Code ships with first-class loop engineering primitives built directly into the CLI. These aren't prompting tricks — they're architectural features that wire up the five building blocks automatically.

/loop
Enter continuous agentic mode. Claude runs the Discover → Plan → Execute → Verify cycle autonomously until a stopping condition is met or you interrupt.
/goal
Set a persistent objective that persists across loop iterations. The agent re-reads the goal at the start of each cycle to stay aligned.
/schedule
Define a time-based or event-based trigger for the loop. Wire the Automations building block without writing a cron job or webhook handler manually.
/workflows
Compose reusable sequences of skills into a named workflow. Workflows are the unit of loop reuse — save a loop pattern once, invoke it anywhere.
⚠️ Token Economics: The Hidden Cost of Unattended Loops

Loops compound. A 10-step loop using a 200K-context model at $15/MTok costs ~$30 per full run. At 100 parallel sub-agents running overnight, that's $3,000 before you've seen the results. Loop Engineering includes budget caps, early exit conditions, and cost dashboards as first-class primitives — not afterthoughts. Always set a token ceiling before you walk away from a running loop.

Research Papers to Read

2022
ReAct: Synergizing Reasoning and Acting in Language Models
The foundational paper. Yao et al. show that interleaving chain-of-thought reasoning traces with tool actions dramatically outperforms either alone. This is the formal origin of the "Think before you Act" loop design.
arxiv.org/abs/2210.03629 →
2023
Toolformer: Language Models Can Teach Themselves to Use Tools
Schick et al. (Meta AI) show how LLMs can learn to call APIs mid-generation — the foundation for Claude's tool_use blocks. Explains why tool use isn't bolted on but integrated into the generation process.
arxiv.org/abs/2302.04761 →
2023
Self-Refine: Iterative Refinement with Self-Feedback
Madaan et al. (CMU) demonstrate that having an LLM critique and refine its own output in a loop consistently outperforms single-pass generation — across code, essay writing, and math. The theoretical backing for the try-it examples above.
arxiv.org/abs/2303.17651 →
2023
Cognitive Architectures for Language Agents (CoALA)
Sumers et al. (Princeton) provide the most complete taxonomy of how language agents are structured — memory types, action spaces, decision procedures. If you want a vocabulary for discussing agent design, this is the reference.
arxiv.org/abs/2309.02427 →
2024
Anthropic's Model Specification (Constitutional AI + Model Card)
Not a research paper, but Anthropic's public documentation on how Claude's agentic behaviour is constrained, how it handles multi-step tool use, and the safety considerations baked into the loop design. Essential reading for anyone building on Claude.
anthropic.com/research →

Best YouTube Videos to Watch

⭐ Andrej Karpathy — "Skill Issue: Code Agents, AutoResearch, and the Loopy Era of AI"
YouTube · 2026 · Andrej Karpathy
Karpathy's defining talk on the "loopy era" of AI — why single-shot generation is over and agent loops running autonomously for hours or days are the new normal. He covers AutoResearch, skill acquisition through loops, and why the bottleneck is now loop design, not model capability. Essential viewing for understanding the Loop Engineering paradigm.
Andrej Karpathy — "Intro to Large Language Models"
YouTube · ~1 hour · Andrej Karpathy
The clearest explanation of how LLMs generate tokens, what "thinking" actually means computationally, and how tool use extends the model's capabilities. He covers the loop concept without calling it that — watching this makes the loop intuitive rather than abstract.
Harrison Chase — "Building Reliable AI Agents with LangGraph"
YouTube · LangChain channel · Harrison Chase
LangGraph makes the loop explicit as a graph you draw and execute. Watching this gives you a visual model of how Think → Act → Observe maps to real code. Best for developers who want to build their own agentic pipelines.
Yannic Kilcher — "ReAct: Synergizing Reasoning and Acting" (#204)
YouTube · Yannic Kilcher
A line-by-line walkthrough of the ReAct paper with live examples. If you read one paper from the list above, watch this video alongside it — Yannic's paper breakdowns are the best in the field for making research immediately applicable.
Anthropic — "Claude's Extended Thinking: Too Powerful?"
YouTube · ~15 min
Shows the loop in action inside Claude specifically — you can watch the internal reasoning steps in real time. Seeing the scratchpad makes the Perceive → Think → Act pattern concrete rather than theoretical.

The One Thing to Take Away

The shift from Prompt Engineering to Loop Engineering isn't about better prompts — it's about better architecture. The loop is no longer something that happens inside a model; it's something you design intentionally, with verifiers, memory, sub-agents, and explicit stopping conditions. Every capability you admire in Claude Code — autonomously fixing bugs, iterating on a failing test suite, running parallel research threads — is a well-engineered loop doing its job.

The developers who will matter most over the next five years aren't the ones who write the cleverest one-shot prompts. They're the ones who architect the most reliable loops: composing the five building blocks, defining honest stopping conditions, capping token budgets, and building verifiers that catch errors before they propagate. The model's raw capability is now table stakes. The loop design is the differentiator.

Prompt engineering asked: "What's the perfect thing to say to the model?" Loop Engineering asks: "What's the perfect system for the model to operate inside?" The second question is harder — and infinitely more powerful.