Ship Production AI Agents from Simple Loops to Multi-Agent
From simple loops to networked agent systems.
An AI agent is a system where a language model decides what actions to take, executes them using tools, observes the results, and iterates — without a human steering each step. Claude's 200K context window, native tool use, and reliable instruction-following make it one of the strongest foundations for production agent systems available today.
What makes a system an “agent”?
Three things separate agents from regular LLM calls:
- 1Autonomous decision-making: The model decides what to do next — which tool to call, what parameters to use, whether to continue or stop — without a human specifying each action.
- 2Tool access and action execution: The agent can interact with the world: query APIs, read and write files, send messages, execute code. Actions have real effects beyond generating text.
- 3Multi-step iteration: The agent observes the result of each action and uses that to inform the next decision. It runs in a loop until the task is complete, handling intermediate failures along the way.
Architecture Patterns
6 agent architectures, from simple to advanced
Memory Systems
How agents remember things
In-context memory
Ephemeral — cleared on session endThe conversation history within a single session. Claude can reference everything said so far. Limited by the context window (200K tokens) but requires no external storage.
External memory (vector store)
Retrieval quality determines effectivenessRelevant documents and past interactions retrieved via semantic search and injected into the context window. Enables memory that spans sessions and scales beyond context limits.
Structured state (database)
Requires explicit state schema designAgent state written to a database between steps. The agent reads its own state at the start of each turn. Enables complex multi-step workflows that survive interruptions and restarts.
Episodic summaries
Lossy — fine detail may be droppedAt the end of each session, a summarization pass condenses the conversation into a compact memory entry. Future sessions load the summary, not the full history.
Code Pattern
The agentic loop in Python
def run_agent(task: str, tools: list, max_turns: int = 10):
messages = [{"role": "user", "content": task}]
for turn in range(max_turns):
response = client.messages.create(
model="claude-opus-4-5",
tools=tools,
messages=messages,
)
# Task complete — no tool calls
if response.stop_reason == "end_turn":
return response.content[0].text
# Execute tool calls and collect results
tool_results = []
for block in response.content:
if block.type == "tool_use":
result = execute_tool(block.name, block.input)
tool_results.append({
"type": "tool_result",
"tool_use_id": block.id,
"content": json.dumps(result),
})
# Add assistant turn + tool results to history
messages.append({"role": "assistant", "content": response.content})
messages.append({"role": "user", "content": tool_results})
raise RuntimeError(f"Agent did not complete in {max_turns} turns")Agent safety: what to get right early
Set a max_turns limit on every agentic loop — never allow unbounded iteration
Flag irreversible actions (send email, delete record, execute payment) for human confirmation
Log every tool call with inputs and outputs — agents are hard to debug without a full action trace
Use a minimal permission model — give the agent only the tools it needs for the current task
Return structured errors from tools, not exceptions — let the agent read and respond to failures
Test with low-stakes variants of production tools before connecting to real systems
Build your first Claude agent
Track 4 covers tool use, agentic loops, and multi-step workflows end-to-end.