AI Agents Patterns Cheat Sheet

AI agent architecture patterns — ReAct, Plan-Execute, multi-agent orchestration, tool-use loop, memory management, and production agent design patterns.

Last Updated: May 1, 2025

Core Agent Patterns

PatternHow It WorksStrengthsLimitations
ReActReason → Act → Observe → RepeatTransparent reasoning, debuggableCan get stuck in loops
Plan-ExecutePlan first → Execute all steps → ValidateEfficient for known tasksInflexible if plan is wrong
Plan-RefinePlan → Execute step → Evaluate → Refine planAdapts to new informationHigher latency, more API calls
ReflexionAct → Evaluate → Reflect → Retry with insightSelf-improving over iterationsRequires good evaluator function
Tree-of-ThoughtsExplore multiple reasoning paths, backtrackComplex problem solvingExpensive — many parallel calls
Multi-Agent OrchestrationMultiple specialized agents collaborateHandles complex workflowsOrchestration overhead
Tool-Use LoopLLM selects tool → executes → observes → decides nextFlexible, general purposeMay call wrong tools
Supervisor-WorkerSupervisor agent delegates to worker agentsClear hierarchy, scalableSingle 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

ItemDescription
LangGraphStateful 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
CrewAIRole-based agent orchestration — assign agents roles like 'Researcher', 'Writer', 'Reviewer'
Supervisor PatternOne agent routes tasks to specialists: 'Send code questions to CodeAgent, research to ResearchAgent'
Debate PatternTwo agents argue opposing viewpoints → supervisor synthesizes consensus — reduces hallucination
Sequential PipelineAgent A output → Agent B input → Agent C input — like a processing pipeline
Shared MemoryAll agents read/write to a shared memory/scratchpad for context sharing
Critic-Refine LoopGenerator agent produces → Critic agent evaluates → Generator refines — iterates until quality threshold met

Production Agent Design

ItemDescription
Tool GovernanceWhitelist tools per user/session. Never expose raw database/API access to agents
Human-in-the-LoopRequire human approval for actions above a risk threshold (send email, make purchase, delete data)
Budget/TokensSet max iterations per task. Agents can loop forever on ambiguous tasks
State PersistenceSave agent state to resume interrupted conversations — use checkpointing
ObservabilityLog every Thought/Action/Observation for debugging. Tools like LangSmith enable tracing
Graceful DegradationIf a tool fails or returns an error, agent should recognize the failure and try alternatives
ConcurrencyRun independent agent sub-tasks in parallel to reduce end-to-end latency
Memory TypesShort-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.