Last Updated: May 1, 2025
Core Agent Patterns
| Pattern | How It Works | Strengths | Limitations |
|---|---|---|---|
| ReAct | Reason → Act → Observe → Repeat | Transparent reasoning, debuggable | Can get stuck in loops |
| Plan-Execute | Plan first → Execute all steps → Validate | Efficient for known tasks | Inflexible if plan is wrong |
| Plan-Refine | Plan → Execute step → Evaluate → Refine plan | Adapts to new information | Higher latency, more API calls |
| Reflexion | Act → Evaluate → Reflect → Retry with insight | Self-improving over iterations | Requires good evaluator function |
| Tree-of-Thoughts | Explore multiple reasoning paths, backtrack | Complex problem solving | Expensive — many parallel calls |
| Multi-Agent Orchestration | Multiple specialized agents collaborate | Handles complex workflows | Orchestration overhead |
| Tool-Use Loop | LLM selects tool → executes → observes → decides next | Flexible, general purpose | May call wrong tools |
| Supervisor-Worker | Supervisor agent delegates to worker agents | Clear hierarchy, scalable | Single point of failure |
ReAct Pattern Implementation
System: "You have access to tools: search(query), calculate(expr), read_file(path). Think step by step about which tool to use and why."System prompt sets up ReAct agent with available tools
Thought: "I need to find the population of Tokyo. I should search for this."Agent verbalizes reasoning before acting (ReAct = Reasoning + Acting)
Action: search("Tokyo population 2024")Agent selects and calls the appropriate tool
Observation: "Tokyo population is approximately 37.4 million in the metropolitan area."Tool result is fed back to the agent for the next reasoning step
Thought: "Now I have the population. The user also asked for the area..."Agent uses observation to decide next action
Stop Condition: "I have all the information to answer the user's question."Agent signals completion when it has gathered sufficient information
Multi-Agent Orchestration
| Item | Description |
|---|---|
LangGraph | Stateful multi-agent graphs — define agent nodes and conditional edges for complex workflows |
AutoGen (Microsoft) | Conversable agents with defined roles — agents chat with each other to solve tasks |
CrewAI | Role-based agent orchestration — assign agents roles like 'Researcher', 'Writer', 'Reviewer' |
Supervisor Pattern | One agent routes tasks to specialists: 'Send code questions to CodeAgent, research to ResearchAgent' |
Debate Pattern | Two agents argue opposing viewpoints → supervisor synthesizes consensus — reduces hallucination |
Sequential Pipeline | Agent A output → Agent B input → Agent C input — like a processing pipeline |
Shared Memory | All agents read/write to a shared memory/scratchpad for context sharing |
Critic-Refine Loop | Generator agent produces → Critic agent evaluates → Generator refines — iterates until quality threshold met |
Production Agent Design
| Item | Description |
|---|---|
Tool Governance | Whitelist tools per user/session. Never expose raw database/API access to agents |
Human-in-the-Loop | Require human approval for actions above a risk threshold (send email, make purchase, delete data) |
Budget/Tokens | Set max iterations per task. Agents can loop forever on ambiguous tasks |
State Persistence | Save agent state to resume interrupted conversations — use checkpointing |
Observability | Log every Thought/Action/Observation for debugging. Tools like LangSmith enable tracing |
Graceful Degradation | If a tool fails or returns an error, agent should recognize the failure and try alternatives |
Concurrency | Run independent agent sub-tasks in parallel to reduce end-to-end latency |
Memory Types | Short-term (conversation history) vs long-term (vector DB) vs episodic (past task summaries) |
Pro Tip: Start simple. A single ReAct agent with 2-3 well-defined tools often outperforms complex multi-agent setups. Add complexity only when simpler approaches demonstrably fail.