Digitorn
Digitorn
All terms
Agent concepts

Agent loop

The core runtime cycle of an agent: think, act, observe, repeat, until the goal is reached.

also known as: think-act-observe loop, react loop, agent runtime loop
In depth

Every agent runs the same three-phase loop. The LLM thinks, picking the next tool to call. The runtime acts, executing the tool. The runtime observes the result and feeds it back into context. Repeat. The loop ends when the LLM emits a final answer instead of another tool call, or when a runtime guard (turn cap, cost cap, behaviour rule) stops it. The loop is what separates an agent from a single LLM call. It is also where most production bugs live: runaway loops, prompt drift, infinite re-edits, all happen inside this cycle.

What it looks like in practice

pseudocode
1while not goal_reached:2    decision = llm.think(context, available_tools)3    if decision.is_final_answer:4        return decision.text5    result = run_tool(decision.tool, decision.args)6    context.append(result)
Related concepts
Read the deep dive

What is an AI agent? A 2026 guide for engineers

Read article
Newsletter

Get the next post in your inbox.

Engineering notes from the Digitorn team. No marketing, no launch announcements, no "10 prompts that will change your life". Just the things we write that we'd want to read.

One-click unsubscribe. We never share your address. Powered by our own infrastructure, not a tracker.

More in Agent concepts

Agent spawn/glossary/agent-spawnAI agent/glossary/ai-agentCompaction/glossary/compactionCoordinator agent/glossary/coordinatorFunction calling/glossary/function-callingGoal pinning/glossary/goal-pinning