An illustration of an agent loop cycling through reason, act and observe, with a toolbelt of shell, code and MCP connections feeding it
Back to blog
Premium
AI AgentsAgentic HarnessAgent Loop

The Agent Loop & Tool Interface: How a Harness Turns a Model Into a Doer

Sascha KieferAI & Agents

Part two of our agentic-harness series opens the hood on the runtime core: the loop that keeps a model working and the tools that let it act. From the ReAct loop to bash as a universal tool, MCP versus CLI, and sandboxes that make autonomy safe.

This is part two of our five-part series on agentic harnesses. In part one we defined the harness as everything wrapping the model and broke it into four parts: the agent loop, the tool interface, context management and control mechanisms. This post opens the hood on the first two, the runtime core that turns a model from a talker into a doer.

The Agent Loop

A bare language model does one thing: given some text, it produces more text. That's a single round-trip. The agent loop is what wraps that round-trip in a cycle so the model can pursue a goal across many steps.

The dominant pattern is the ReAct loop: the model reasons about what to do next, takes an action through a tool, observes the result, and goes around again, all inside a plain while loop that runs until the goal is met.

The main agent execution pattern today is a ReAct loop, where a model reasons, takes an action via a tool call, observes the result, and repeats in a while loop.

This idea has a lineage. ReAct-style reasoning loops appeared in 2022, AutoGPT popularised long-running autonomy in 2023, and the "Ralph loop" (a bash one-liner that keeps re-running an agent until it finishes) made the rounds in 2025. By 2026 the pattern was productised directly into tools like Codex and Claude Code as /loop and /goal commands.

A cycle: reason about what to do next, act by calling a tool, observe the result, then check whether the goal is met - if not, loop back to reason; if yes, finish

The loop sounds trivial, but the craft is in its edges. When should it continue, and when should it stop? How does it recover from a tool that errors or a step that went sideways? How do you keep it from spinning forever on a task it can't finish? A good loop has clear stopping conditions and a way to back out of a dead end, and that's the difference between an agent that finishes and one that loops uselessly.

Premium article

Read the full article

Enter your email and we'll send you a link to the complete article — it's free.