Agent Architectures: How They Plan and Act
2 / 5Understanding how agents work internally helps you design better agents and diagnose why they fail. This lesson covers the key architectural patterns.
The ReAct Pattern
The most widely used agent architecture is called ReAct (Reasoning + Acting). The loop works like this:
- 1.Thought: The LLM reasons about the current state and what to do next
- 2.Action: The LLM calls a tool (e.g., web search, code execution, file write)
- 3.Observation: The result of the action is returned to the LLM
- 4.Repeat: The LLM uses the observation to decide the next thought and action
This loop continues until the LLM determines the goal is complete or it cannot proceed.
The key insight: reasoning and acting are interleaved. The agent does not plan everything upfront and then execute; it plans incrementally based on what it observes.
Tool Use: How Agents Interact with the World
An agent without tools can only produce text. Tools are what give agents the ability to affect the world.
Common tool categories:
- Information retrieval
- Web search (Google, Bing APIs)
- Document retrieval (semantic search over a knowledge base)
- Database queries
- Code execution
- Python REPL (for calculations, data analysis, file manipulation)
- Shell command execution (more powerful, more dangerous)
- Communication
- Email (read, write, send)
- Calendar (read, create events)
- Slack, Teams, or other messaging
- External services
- REST API calls (any web service with an API)
- Browser automation (navigate and interact with websites)
- File and storage operations
- Read and write files
- Create, update, and query databases
The principle: any deterministic, callable function can be a tool.
Multi-Agent Architectures
For complex tasks, multiple specialised agents working together often outperform a single generalist agent.
Orchestrator/worker pattern: An orchestrator agent receives a high-level goal, breaks it into sub-tasks, and delegates to specialised worker agents. Workers report back; the orchestrator synthesises results and decides on next steps.
Parallel agents: Multiple agents work on independent aspects of a problem simultaneously, then their results are combined.
Reviewer/critic pattern: One agent produces a result; a second agent reviews it for quality, accuracy, or safety; a third agent incorporates the review.
Memory in Agents
In-context memory (short-term): Everything in the current LLM context window. Limited by context window size. Effective for tasks that fit within a single session.
External memory (long-term): Results and observations stored outside the model, retrieved when relevant. Allows agents to maintain state across sessions. Implemented as vector databases, key-value stores, or structured databases.
Episodic memory: A log of past actions and outcomes the agent can refer to when solving similar problems. Important for learning from previous runs.
The memory architecture has a significant impact on what kinds of tasks an agent can successfully handle.