An "agent" sounds magical, but underneath it is one small loop running over and over: think → act → look → repeat. Press play and watch a real agent solve a task one turn at a time. Once you can see the loop, every agent bug ("it never stops", "it forgot the goal", "it called the wrong tool") has an obvious home.
The model never touches the outside world directly. Each turn it either asks for a tool (an action it wants taken) or gives a final answer. Your code runs the tool, appends the result to the conversation, and calls the model again — that "call again with the result attached" is the entire trick. Step through a customer-support agent answering "Where is order #4471 and can I still cancel it?"
| Part | What it is | Where it breaks in production |
|---|---|---|
| Model turn | Claude reads the whole conversation and decides: call a tool, or answer. | Vague task → it guesses; too many tools → it picks the wrong one. |
| Tool execution | Your code runs the requested action and captures the result. | Tool throws, times out, or returns a wall of unstructured text. |
| Result append | The result is added to the message history as a tool_result. | Result too big → blows the context window (Domain 5). |
| Stop check | Loop until the model answers or a limit (max turns / budget) is hit. | No cap → runaway loop, burning tokens forever. |
tool_use
request; your harness executes it and feeds back a tool_result. Every "the agent did X"
is really "the model asked, the harness did X." Knowing exactly where the boundary sits is half of Domain 1.Notice the conversation only ever gets longer: each turn appends the model's request and the tool's result. That accumulating transcript is the agent's only memory — there is no hidden state. This is why long agent runs eventually hit the context window and need compaction (Domain 5), and why a clear running goal matters: on turn 12 the model re-reads everything from turn 1 to decide turn 13.
Curated companion: Anthropic — Building Effective Agents · Tool use overview.