By Sagar Shankaran, Founder of CallSphere
How a Claude agent is wired internally — model loop, context store, tool router, MCP layer, and control plane — with a diagram, code, and pitfalls.
Key takeaways
Most teams discover the hard way that an agent is not a model with a system prompt taped to a few API calls. It is a small distributed system that happens to have a language model at its center. When a Claude agent stalls, loops, or burns through a budget, the cause is almost never the model — it is some seam in the architecture: a context store that grew unbounded, a tool router that returned ambiguous results, or a control loop that never decided when to stop. This post walks the full anatomy of an effective Claude agent so you can reason about each piece independently.
I will use the vocabulary of the Claude ecosystem in 2026 — the model loop, Model Context Protocol (MCP) servers, Agent Skills, and the orchestrator pattern — but the architecture generalizes. The goal is a mental model precise enough that, when something breaks at 2 a.m., you know which box on the diagram to open.
An AI agent is a system that uses a language model to choose its own sequence of actions toward a goal, observing the results of each action before deciding the next. The defining word is chooses: a workflow with hard-coded steps is not an agent, even if every step calls Claude. An agent earns the name when the model — not your code — decides what happens next.
Concretely, a Claude agent is a loop wrapped around the Messages API. Each iteration sends the current context to the model, the model responds either with a final answer or a request to call one or more tools, your runtime executes those tool calls, appends the results, and loops again. Everything else in the architecture exists to make that loop reliable, observable, and bounded.
It helps to separate concerns into five planes, each with a single responsibility. The model loop drives decision-making. The context store holds the working state passed to the model. The tool router turns a model's tool request into a concrete execution. The capability layer — MCP servers plus Skills — is the catalog of what the agent can do and how. The control plane enforces budgets, retries, and safety. Here is how a single request flows through them.
Hear it before you finish reading
Talk to a live CallSphere AI voice agent in your browser — 60 seconds, no signup.
flowchart TD
A["Incoming goal"] --> B["Context store assembles state"]
B --> C["Model loop: Claude decides"]
C --> D{"Tool call requested?"}
D -->|No| E["Return final answer"]
D -->|Yes| F["Tool router resolves target"]
F --> G["MCP server / Skill executes"]
G --> H["Observation appended to context"]
H --> I{"Control plane: budget & stop check"}
I -->|Continue| C
I -->|Halt| E
Read the diagram as a cycle with one escape hatch. The control plane sits deliberately after the observation step, because that is the only safe place to ask "should we keep going?" — after you have spent tokens and learned something, before you spend more. Teams that put the budget check at the top of the loop tend to halt agents that were one cheap step from finishing.
The model loop is the heart, and its shape is simpler than people expect. On each turn you call Claude with the system prompt, the curated context, and the tool definitions. Claude returns content blocks; a tool_use block is a request, not an execution. Your runtime is responsible for executing it and returning a matching tool_result. Here is the minimal skeleton with the Agent SDK style:
while not done:
resp = client.messages.create(
model="claude-opus-4-8",
system=SYSTEM_PROMPT,
messages=context.render(),
tools=tool_catalog,
max_tokens=4096,
)
if resp.stop_reason == "tool_use":
for block in resp.tool_use_blocks():
result = router.execute(block.name, block.input)
context.add_tool_result(block.id, result)
else:
done = True
budget.charge(resp.usage)
if budget.exceeded() or context.turns > MAX_TURNS:
done = True
Notice that done can be set two ways: Claude decides it is finished, or the control plane forces a stop. Both paths must exist. An agent with only the first path will, on a bad day, loop forever calling the same tool with slightly different arguments.
The single biggest architectural lever is treating context as a managed store rather than an ever-growing transcript. With Claude's 1M-token window it is tempting to just append everything, but a bloated context degrades decision quality and cost long before you hit the limit. Effective agents curate: they summarize old tool results, drop stale observations, pin the goal and key constraints, and keep only the last few raw exchanges verbatim.
A good context store exposes operations like pin(fact), summarize(range), and evict(predicate). The control plane calls these between turns. The model never sees your bookkeeping — it sees a clean, relevant working set every time, which is exactly what keeps a long-running agent coherent over dozens of steps.
If the model loop is the heart, the control plane is the nervous system that keeps the agent from hurting itself. It owns three things no other plane should touch: budgets, retries, and guardrails. A budget is a running tally of tokens and wall-clock time with a hard ceiling. Retries are bounded re-attempts of failed tool calls with backoff, never unlimited. Guardrails are the checks that run before a risky action commits — a confirmation gate on an irreversible write, a rate limit on outbound calls, a deny-list of operations the agent simply may not perform.
Still reading? Stop comparing — try CallSphere live.
CallSphere ships complete AI voice agents per industry — 14 tools for healthcare, 10 agents for real estate, 4 specialists for salons. See how it actually handles a call before you book a demo.
The reason to concentrate these in one plane is testability. When budgets, retries, and stops are scattered across prompts and tool bodies, you cannot reason about the agent's worst case. When they live in one control plane, you can write a test that asserts "this agent never spends more than N tokens" and actually trust it. That single property — a provable upper bound on cost and blast radius — is most of what stands between a demo and something you would run against production data.
An agent you cannot replay is an agent you cannot debug. Bake in a trace from the start: a per-run record of every turn's input context, the model's decision, the tool calls, their results, and the token usage. Key it by a run ID and store it somewhere queryable. When an agent does something inexplicable, you do not reason about it abstractly — you open the trace and watch, turn by turn, where the decision went sideways. Almost every "the model is broken" report turns out, on replay, to be a tool that returned ambiguous data or a context that lost the goal.
render(), add_tool_result(), and summarize() methods.| Concern | Owned by | Anti-pattern if misplaced |
|---|---|---|
| What to do next | Model loop | Hard-coding in your runtime kills agency |
| What the model sees | Context store | Unbounded append degrades quality |
| How a tool runs | Tool router | Logic in the prompt is untestable |
| When to stop | Control plane | No owner means infinite loops |
A workflow has a fixed graph of steps you author; an agent lets the model choose the next step at runtime based on observations. Workflows are more predictable and cheaper; agents handle open-ended tasks. Many production systems are hybrids: deterministic scaffolding with an agentic core for the genuinely uncertain parts.
MCP servers live in the capability layer, behind the tool router. The router translates a Claude tool_use request into an MCP call, the server returns structured data, and that data becomes an observation in the context store. Claude never talks to your database directly — it goes through the MCP boundary, which is what makes the system auditable.
Almost never. Multi-agent runs typically consume several times more tokens than a single agent and add coordination complexity. Get the single-agent loop solid first; reach for orchestrator-subagent patterns only when a task genuinely decomposes into parallel, independent subtasks.
CallSphere applies these same agentic-AI patterns to voice and chat — multi-agent assistants that answer every call and message, use tools mid-conversation, and book work 24/7. See it live at callsphere.ai.
Source & attribution: This is an independent, original explainer inspired by Anthropic's coverage on the Claude blog. Claude, Claude Code, Claude Cowork, Claude Opus, and the Model Context Protocol are products and trademarks of Anthropic. CallSphere is not affiliated with or endorsed by Anthropic.

Written by
Sagar Shankaran· Founder, CallSphere
LinkedInSagar Shankaran is the founder of CallSphere, where he builds production AI voice and chat agents deployed across healthcare, hospitality, real estate, and home services. He writes about agentic AI, LLM engineering, and shipping voice agents that handle real calls in production.
See how AI voice agents work for your industry. Live demo available -- no signup required.
How AI that writes inside ServiceTitan instead of living in a separate tab removes about 29 hours a month of supply ticket matching and equipment re-keying.
Independent lots key each auction VIN into six systems. In 2026 assistants write inside the dealer management system itself. What it saves on a 60-car lot.
A homebuilder's variance purchase order is keyed four times before it hits job cost. MCP lets AI write in the system of record and stops the margin leakage.
Why roofing shops key the same roof three times, and how 2026's MCP connectors let an assistant write squares and material orders into the system of record.
One load of corn gets typed in four times between the field and the checkbook. What the 2026 common plug between AI and farm software actually removes.
Leasing agents re-key the same renter into four systems before a showing. Here is what write access to the system of record changes for a rental portfolio.
© 2026 CallSphere Inc. All rights reserved.
Made within San Francisco
Watch how CallSphere handles real customer calls, schedules appointments, and processes payments — live.
Try Live DemoBook a DemoCalculate Your ROI