Skip to content

iuyup/AgentFlow

Folders and files

NameName
Last commit message
Last commit date

Latest commit

ย 

History

38 Commits
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 

Repository files navigation

๐Ÿ”€ AgentFlow

็ฎ€ไฝ“ไธญๆ–‡ | 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

AgentFlow Overview

Architecture Overview

Architecture Overview

Pattern: Reflection (Iterative Self-Improvement)

Reflection Pattern

Pattern: MapReduce (Parallel Fan-Out)

MapReduce Pattern

Screenshots & demos: See the documentation site for interactive examples and run screenshots.

Why AgentFlow?

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.

Patterns

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 โœ…

Quick Start

1. Clone & install

git clone https://github.com/iuyup/AgentFlow.git
cd AgentFlow
uv sync

2. Set up your API key

cp .env.example .env
# Edit .env and add your OpenAI API key

3. Run any pattern

python -m patterns.reflection.example
python -m patterns.debate.example
python -m patterns.map_reduce.example

4. Browse documentation

cd web
pip install -r requirements.txt
python sync_docs.py
mkdocs serve
# Visit http://localhost:8000

Project Structure

patterns/                  # 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

Documentation Site

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

Requirements

  • Python 3.11+
  • An OpenAI API key (default model: gpt-4o-mini)

Running Tests

# Unit tests (no API key needed)
pytest patterns/

# Integration tests (requires OPENAI_API_KEY)
OPENAI_API_KEY=your-key pytest patterns/ -m "not skipif"

Design Philosophy

  1. Patterns, not frameworks โ€” Each pattern is self-contained. Copy what you need.
  2. Runnable in 3 minutes โ€” Clone, set API key, run. That's it.
  3. Dual-language docs โ€” English README + Chinese README for every pattern.
  4. Real LangGraph โ€” No abstractions over LangGraph. Learn the real API.

Contributing

See CONTRIBUTING.md for contribution guidelines.

License

MIT

About

Multi-Agent Collaboration Design Patterns Built on LangGraph with 10+ battle-tested patterns, each with complete code, architecture diagrams, and benchmarks.

Topics

Resources

License

Contributing

Stars

Watchers

Forks

Contributors