็ฎไฝไธญๆ | English
Multi-Agent Collaboration Design Patterns with LangGraph
AgentFlow is a curated collection of battle-tested multi-agent design patterns built on LangGraph. Each pattern includes complete code, architecture diagrams, use-case analysis, and performance comparisons.
Not a framework. Not a tutorial collection. This is a design pattern reference book for multi-agent systems.
Live Demo: https://iuyup.github.io/AgentFlow
Screenshots & demos: See the documentation site for interactive examples and run screenshots.
Building multi-agent systems is hard. Not because of the tools, but because of the architecture decisions:
- When should agents loop vs. terminate?
- How do you coordinate N agents without chaos?
- When is fan-out better than sequential processing?
AgentFlow gives you proven patterns you can study, adapt, and combine โ each one a complete, runnable example.
| Pattern | Description | Key Technique | Status |
|---|---|---|---|
| Reflection | Iterative self-improvement through write โ review loops | Conditional looping | โ |
| Debate | Multi-perspective deliberation with moderator synthesis | N-party coordination | โ |
| MapReduce | Parallel fan-out processing with result aggregation | LangGraph Send API | โ |
| Hierarchical | Manager decomposes tasks โ Workers execute โ Manager aggregates | Nested subgraphs + Send | โ |
| Voting | Multiple agents independently vote, then aggregate | Broadcast fan-out | โ |
| GuardRail | Primary agent + safety guard checkpoint | Approve/block/redirect routing | โ |
| RAG-Agent | Agent decides when to retrieve from knowledge base | Conditional retrieval loop | โ |
| Chain-of-Experts | Task passes through specialized agents in sequence | Sequential routing | โ |
| Human-in-the-Loop | Key nodes wait for human confirmation | Interrupt + resume | โ |
| Swarm | Decentralized multi-agent collaboration | Dynamic orchestration | โ |
| Self-Improving | Persistent skill library + cross-task learning | Layered memory + progressive disclosure | โ |
git clone https://github.com/iuyup/AgentFlow.git
cd AgentFlow
uv synccp .env.example .env
# Edit .env and add your OpenAI API keypython -m patterns.reflection.example
python -m patterns.debate.example
python -m patterns.map_reduce.examplecd web
pip install -r requirements.txt
python sync_docs.py
mkdocs serve
# Visit http://localhost:8000patterns/ # Core: one directory per pattern
โ โโโ reflection/ # Write โ Review loop
โ โโโ debate/ # N-party debate + moderator
โ โโโ map_reduce/ # Parallel fan-out + reduce
โ โโโ hierarchical/ # Manager โ Workers โ aggregation
โ โโโ voting/ # Multi-agent voting + aggregation
โ โโโ guardrail/ # Primary + safety checkpoint
โ โโโ rag_agent/ # Agent with conditional retrieval
โ โโโ chain_of_experts/ # Sequential expert routing
โ โโโ human_in_the_loop/ # Human interruption
โ โโโ swarm/ # Decentralized orchestration
| โโโ self_improving/ # Self iteration
โโโ agentflow/ # Core utilities
โโโ web/ # Documentation site (MkDocs)
โ โโโ docs/ # Documentation source
โ โโโ mkdocs.yml # Site configuration
โ โโโ sync_docs.py # Pattern doc sync script
โโโ benchmarks/ # Performance comparison framework
โโโ docs/ # Architecture diagrams & assets
The documentation site is built with MkDocs + Material and deployed at web/:
# Local preview
cd web
pip install -r requirements.txt
python sync_docs.py # Sync pattern docs
mkdocs serve # Visit http://localhost:8000
# Build static site
mkdocs build
# Deploy to GitHub Pages
mkdocs gh-deploy- Python 3.11+
- An OpenAI API key (default model:
gpt-4o-mini)
# Unit tests (no API key needed)
pytest patterns/
# Integration tests (requires OPENAI_API_KEY)
OPENAI_API_KEY=your-key pytest patterns/ -m "not skipif"- Patterns, not frameworks โ Each pattern is self-contained. Copy what you need.
- Runnable in 3 minutes โ Clone, set API key, run. That's it.
- Dual-language docs โ English README + Chinese README for every pattern.
- Real LangGraph โ No abstractions over LangGraph. Learn the real API.
See CONTRIBUTING.md for contribution guidelines.
MIT