A practical reference library of agentic design patterns with Python implementations and runnable demos.
react-loop/- Reasoning + acting loop with tool callsplan-and-execute/- Planning/execution state machine with multiple strategiesmulti-agent-debate/- Multi-role collaborative reasoningcircuit-breaker/- Reliability guard for LLM/tool callsmemory-hierarchy/- Working, episodic, and semantic memory layersobserver-pattern/- Event bus and pub/sub coordination modeltool-use-mcp/- MCP-style tool registry + execution adapter
| Pattern | Use When | Don't Use When | Complexity | Best For |
|---|---|---|---|---|
| ReAct Loop | Tasks requiring reasoning + action cycles | Simple, single-step tasks | Low | Interactive problem-solving, tool use |
| Plan-and-Execute | Complex, multi-step tasks with clear subgoals | Real-time, streaming tasks | Medium | Research, data processing workflows |
| Multi-Agent Debate | Need diverse perspectives, complex decisions | Simple tasks, cost-sensitive | High | Creative tasks, ethical decisions, review |
| Circuit Breaker | Production systems with external LLM calls | Prototypes, internal tools | Low | Reliability, cost control |
| Memory Hierarchy | Long-running agents with learning | Stateless, one-shot tasks | Medium | Personal assistants, knowledge agents |
| Observer Pattern | Event-driven coordination, reactive systems | Simple linear workflows | Medium | Real-time monitoring, multi-agent systems |
| Tool Use (MCP) | Integrating external tools/resources | No external dependencies | Medium | Tool-augmented agents |
Reasoning + Acting cycles
The ReAct pattern interleaves reasoning (thought) and action steps. The agent thinks about what to do, performs an action (like calling a tool), observes the result, and repeats until the task is complete.
- When to use: Interactive problem-solving, tool-using agents, tasks requiring step-by-step reasoning
- Key benefit: Transparent decision-making process, easy to debug
- See: /react-loop/README.md
Decomposition + execution
Breaks complex tasks into a plan of subtasks, then executes them sequentially or in parallel. Often uses a planner LLM and an executor LLM/agent.
- When to use: Multi-step workflows, research tasks, data processing pipelines
- Key benefit: Structured approach to complex problems, parallelization opportunities
- See: /plan-and-execute/README.md
Multiple agents discussing solution
Multiple specialized agents discuss a problem, propose solutions, critique each other's ideas, and reach a consensus or best answer.
- When to use: Complex decisions requiring diverse perspectives, creative tasks, code review
- Key benefit: Higher quality outputs through collaboration and critique
- See: /multi-agent-debate/README.md
Fail fast for LLM failures
Prevents cascading failures by stopping requests when error rates or costs exceed thresholds. Essential for production systems.
- When to use: Production agents, cost-sensitive applications, high-availability systems
- Key benefit: System resilience, cost control
- See: /circuit-breaker/README.md
Working + episodic + semantic memory
Implements a multi-layered memory system: working memory (current context), episodic memory (past experiences), and semantic memory (general knowledge).
- When to use: Long-running agents, learning systems, personal assistants
- Key benefit: Contextual awareness, learning from experience
- See: /memory-hierarchy/README.md
Event-driven agent coordination
Agents subscribe to events and react to changes. Enables loose coupling and reactive behavior in multi-agent systems.
- When to use: Real-time systems, event-driven workflows, multi-agent coordination
- Key benefit: Loose coupling, reactive responses
- See: /observer-pattern/README.md
Model Context Protocol integration
Standardized way for LLMs to discover and use external tools following the Model Context Protocol specification.
- When to use: Tool-augmented agents, API integrations, resource access
- Key benefit: Standardized tool interface, dynamic tool discovery
- See: /tool-use-mcp/README.md
Start with ReAct Loop - it's the foundation of most agent systems.
Combine Plan-and-Execute with ReAct - plan the approach, then use ReAct for each subtask.
Always add Circuit Breaker for reliability.
Implement Memory Hierarchy to maintain context across sessions.
Use Observer Pattern for coordination and Multi-Agent Debate for quality.
These patterns are particularly visual and educational for video content:
- Multi-Agent Debate - Great for showing agents "talking" to each other
- ReAct Loop - Clear step-by-step visualization of reasoning
- Memory Hierarchy - Visual memory layers and retrieval
- Plan-and-Execute - Flowchart-style plan visualization
- Circuit Breaker - State machine transitions (Closed/Open/Half-Open)
python -m venv .venv
source .venv/bin/activate
pip install -r requirements.txtEach pattern includes a runnable example:
cd react-loop
python example.pySome examples require OPENAI_API_KEY. If unset, most demos fall back to mock mode.
python3.11 -m unittest discover -s tests -v- This repo is a reference implementation, not a complete production framework.
- Several patterns intentionally keep simple heuristics for readability (for example consensus detection and plan parsing).
- Security-sensitive components are guarded where appropriate (for example filesystem tool paths are constrained to a configured base directory).
Add new patterns following the same structure:
README.md- Concept explanationdiagram.md- Architecture diagramimplementation.py- Core implementationexample.py- Usage example