Domain 1 · Agentic Architecture

The agent loop

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.

agentic looptool use stop conditionscontext accumulation max turns
Explain like I'm 10
Imagine you send a clever robot to bake a cake but it can't see the kitchen. So it works like this: it says out loud what it wants ("I need flour"), you go fetch the flour and tell it what you found ("here's 2 cups"), and then it thinks again about the next step. Talk, fetch, think — over and over — until the cake is done. The robot is Claude. The "fetching" is a tool. That talk-fetch-think circle is the agent loop.

Watch the loop run

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?"

The four parts every loop has

PartWhat it isWhere it breaks in production
Model turnClaude reads the whole conversation and decides: call a tool, or answer.Vague task → it guesses; too many tools → it picks the wrong one.
Tool executionYour code runs the requested action and captures the result.Tool throws, times out, or returns a wall of unstructured text.
Result appendThe result is added to the message history as a tool_result.Result too big → blows the context window (Domain 5).
Stop checkLoop until the model answers or a limit (max turns / budget) is hit.No cap → runaway loop, burning tokens forever.
Exam trap: the model does not run tools. It only emits a 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.

Why context grows every turn

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.

Takeaways: an agent = a loop of model turn → tool execution → append result → stop check. The model only requests actions; your harness performs them. The transcript is the agent's entire memory, so it grows every turn. Always bound the loop (max turns + budget) and give a crisp goal, or you get runaway loops and lost objectives — the two failures Domain 1 loves to test.

Curated companion: Anthropic — Building Effective Agents · Tool use overview.