Agent Loop
An agent loop is the control-flow pattern at the center of every autonomous LLM agent: the model observes its context, reasons about what to do, calls a tool, reads the result, and loops — until it produces plain text with no more tool calls, or a budget rule cuts the cycle. In the canonical form, the whole mechanism is about nine lines of Python.
What's new in 2026 is canonicalization. OpenAI's Jan 23, 2026 "Unrolling the Codex agent loop" (456 HN points) used the phrase as a product-page title. Letta's "Rearchitecting Letta's Agent Loop" placed it alongside ReAct, MemGPT, and Claude Code. Every major platform voice — OpenAI, Anthropic, LangChain, Letta, IBM — converged on the same two-word label.
Sketch.dev's "The unreasonable effectiveness of an LLM agent loop with tool use" (447 HN points, May 2025) published the reference nine-line implementation: `while True: output, tool_calls = llm(msg); if tool_calls: msg = [handle(tc) for tc in tool_calls] else: msg = user_input()`. Claude Code's master loop (codenamed nO) is the same pattern hardened with an async dual-buffer queue.
It's the REPL of the AI era — read-eval-print, except "eval" is a frontier model and "print" can touch your filesystem and production database.
Search Interest
-
Nascent0–7 days
-
Emergent8–30 days
-
Validating31–90 days
-
Rising91–180 days
-
Established ← now180 days +
Why is it emerging now?
Three years after ReAct named the pattern, "agent loop" hit canonical status in 2026 when OpenAI, Letta, and PromptLayer all used the exact phrase in flagship posts within 12 months. A 2026 wave of cost-horror stories (one team going from $127/wk to $47k/wk) keeps the term sticky.
Outlook
6-month signal projection and commercial timeline.
Every major agent vendor converged on the same two-word label within a 12-month window, locking in the category name.
Risk · The term gets absorbed into "agent harness" as the broader noun and loses distinct SEO identity.
Analogs · ReAct · event loop · REPL · agent harness
-
nowInformational, paid one layer up
Searchers are builders learning the pattern; paid products live on hosted harnesses and managed agents.
-
3-6moDebuggers + runaway guards
Agent-loop debuggers, runaway-loop guards, replay tools, and comparison posts ship as paid SaaS.
-
6-12moSwallowed by harness?
Either the noun holds or gets absorbed into "agent harness" like event loop under Node.js.
Competition & Opportunity for term “Agent Loop”
Three heuristic signals derived from the tracked queries, the term's monetization cards, and its cluster neighbors. Directional, not audited.
Ideas for term “Agent Loop”
Buildable pitches — turn this term into an article, site, product, post, newsletter, video, or course. Steal any card and run with it.
The sketch.dev reference stops where it gets interesting. Walk through token ceilings, step limits, retry policy, tool timeouts, context compaction, structured logs.
Node.js/Python devs keep asking this. Crisp comparison naming the shared structure (read, act, yield) and the one big difference (nondeterministic eval).
Listicle aggregating loop variants people are shipping. Ralph Loop, reflection loops, plan-and-execute, nested sub-agent loops, stateful heartbeats.
The cost-horror framing is begging for a definitive guide. Walks through actual failure modes with diagnostic code. Strong commercial intent.
Interactive site (no login, BYO API key) running the same task through four canonical variants, showing cost, steps, and success. No such comparison exists.
npm / pypi package wrapping any agent loop with max-steps, max-tokens, max-wall-clock, max-dollar circuit breakers. $47k story makes this a paid B2B sell.
Local-first debugger recording every iteration's messages, tool calls, token counts; scrub back and replay with modifications. Builders stitch this manually today.
CLI reading a LangGraph/LangChain agent definition and emitting a plain Python/TypeScript while-loop equivalent. Aligned with the "harness > framework" shift.
In May 2025, sketch.dev printed nine lines of Python and called it an agent. Three years of frameworks later, the nine lines are still the nine lines.
I ripped the control-flow out of Claude Code, Codex, LangGraph, CrewAI, and OpenHarness. The core loop is literally identical.
One team's agent bill went from $127/week to $47,000/week. The model didn't change. The prompt didn't change. The loop did.
What People Search
Long-tail queries from Google Suggest + Trends. Volume and competition are heuristics — directional, not audited. Content Type comes from query shape.
SERP of term “Agent Loop”
What searchers see today — organic results on top, paid ads if anyone's bidding. Ad density is a real-time commercial signal.
Related Terms
Other terms in the same space — aliases, subtypes, competitors, and neighbors to explore next.
- Part of Agent Harness An agent harness is the middleware between a large language model and the real world — code that runs the agent loop, calls tools,… →
- Part of Managed Agents Managed Agents is an infrastructure paradigm where cloud platforms host, orchestrate, and operate AI agents as a service. →
- Related Coding Agents Coding Agents is the category name for AI developer tools that act on code autonomously — reading a repo, planning a change, editing… →
- Related Claude Agent SDK Claude Agent SDK is Anthropic's programmatic toolkit for building AI agents on Claude. →
- Also known as agentic loop·LLM loop·agent execution loop
- Part of ReAct
- Includes Ralph Loop
- Related event loop·MemGPT·LangGraph
Sources
Primary URLs this report cites — open any to verify the claim yourself.
- 01 sketch.dev — The unreasonable effectiveness of an LLM agent loop with tool use (reference 9-line implementation) sketch.dev ↗
- 02 OpenAI — Unrolling the Codex agent loop openai.com ↗
- 03 Letta — Rearchitecting Letta's Agent Loop: Lessons from ReAct, MemGPT & Claude Code letta.com ↗
- 04 PromptLayer — Claude Code: Behind-the-scenes of the master agent loop (nO) blog.promptlayer.com ↗
- 05 Steve Kinney — The Anatomy of an Agent Loop stevekinney.com ↗
- 06 Victor Dibia — The Agent Execution Loop: How to Build an AI Agent From Scratch newsletter.victordibia.com ↗
- 07 TianPan.co — Agentic Engineering Patterns: The While Loop Is the Easy Part tianpan.co ↗
- 08 Alibaba Cloud — From ReAct to Ralph Loop: A Continuous Iteration Paradigm for AI Agents alibabacloud.com ↗
- 09 Hacker News — Unrolling the Codex agent loop (456 points) news.ycombinator.com ↗
- 10 Hacker News — The unreasonable effectiveness of an LLM agent loop with tool use (447 points) news.ycombinator.com ↗
- 11 snarktank/ralph — autonomous AI agent loop (17.1k stars) github.com ↗