An educational TypeScript project for learning different multi-agent architectures using LangChain and LangGraph. This platform provides hands-on experience with 5 distinct architectural patterns, featuring verbose console output to help students understand how agents interact and coordinate.
- Understand different multi-agent coordination patterns
- See how agents spawn, communicate, and complete tasks
- Compare architectural trade-offs (speed vs. quality, simplicity vs. flexibility)
- Learn LangGraph state management and graph construction
- Observe LLM calls, tool usage, and reasoning in real-time
Pattern: Linear execution where each agent builds on the previous agent's output.
Best For: Tasks with clear sequential dependencies (analyze β process β synthesize)
Key Concept: Fixed execution order with state accumulation
Pattern: Classifies input and routes to specialized agents based on task type.
Best For: Diverse requests requiring different expertise (math, text, code)
Key Concept: Conditional routing with specialized agents
Pattern: Multiple agents execute simultaneously, results are aggregated.
Best For: Independent subtasks that can run concurrently (intro, body, conclusion)
Key Concept: Fan-out/fan-in with concurrent execution
Pattern: Generator creates content, critic reviews it, iterates until acceptable.
Best For: Tasks requiring quality refinement (writing, code generation)
Key Concept: Cycles in graph for iterative improvement
Pattern: Manager coordinates specialized workers, reviews outputs, synthesizes final result.
Best For: Complex tasks requiring multiple specialized skills (research, analysis, writing)
Key Concept: Two-level coordination with central oversight
- Node.js 18+
- npm or yarn
- An API key for at least one LLM provider (OpenAI, Anthropic, or local Ollama)
# Clone or navigate to the project
cd agents-playground
# Install dependencies
npm install
# Setup environment
cp .env.example .env
# Edit .env and add your API keysEdit .env file:
# Choose your LLM provider
LLM_PROVIDER=openai # or anthropic, ollama
# Add API key for your provider
OPENAI_API_KEY=your-key-here
# ANTHROPIC_API_KEY=your-key-here
# OLLAMA_BASE_URL=http://localhost:11434
# Logging verbosity
LOG_LEVEL=verbose # verbose, normal, or minimalnpm startThis launches an interactive menu where you can:
- Select an architecture
- Enter your task
- Watch the agents work with verbose logging
- Compare different architectures on the same task
Every architecture provides detailed, color-coded output showing:
- π€ Agent Spawning: See when agents are created and their roles
- π§ LLM Calls: View prompts sent to the LLM and responses received
- π§ Tool Usage: Observe when agents use calculator, search, or other tools
- π Reasoning: Follow agent thinking and decision-making
- β‘ Transitions: Track how control flows between agents
- π Final Results: See the completed output
ββββββββββββββββββββββββββββββββββββββββββ
β Sequential Architecture β
β β
β Agents execute in linear order, β
β each building on previous output β
ββββββββββββββββββββββββββββββββββββββββββ
ββ π€ Agent Spawned: Analyzer
β Role: Input Analysis
β Input: "Write a blog post about TypeScript"
π§ LLM Call (gpt-4-turbo-preview)
Prompt: You are an Analyzer agent...
β LLM responded
Response: I'll analyze this task...
ββ β Agent Complete: Analyzer
β‘ Transition: analyzer β processor
- Start with Sequential - simplest pattern
- Try Router - adds conditional logic
- Explore Parallel - introduces concurrency
- Study Reflection - adds iteration
- Master Hierarchical - most complex
- Read the architecture's README
- Review the diagram and flow
- Run the example with verbose logging
- Examine the code (nodes.ts and graph.ts)
- Try different tasks to see how it behaves
- Run the same task across all architectures and compare outputs
- Modify max iterations in Reflection (1, 3, 5, 10)
- Add a new specialist to Router (e.g., "science" specialist)
- Create custom tasks that favor certain architectures
- Combine patterns (e.g., Router + Reflection)
agents-playground/
βββ src/
β βββ index.ts # Interactive CLI
β βββ shared/ # Shared utilities
β β βββ config/ # LLM provider configuration
β β βββ logging/ # Educational console logger
β β βββ tools/ # Calculator & search tools
β β βββ types/ # State type definitions
β βββ architectures/ # Architecture implementations
β βββ sequential/ # Chain pattern
β βββ router/ # Routing pattern
β βββ parallel/ # Concurrent pattern
β βββ reflection/ # Iterative pattern
β βββ hierarchical/ # Manager-worker pattern
βββ package.json
βββ tsconfig.json
βββ .env.example
βββ README.md
Each architecture folder contains:
README.md- Documentation with diagrams and explanationsnodes.ts- Agent node implementationsgraph.ts- LangGraph workflow definition
Simply change LLM_PROVIDER in .env:
openai- GPT-4, GPT-3.5anthropic- Claude modelsollama- Local models (Llama, Mistral, etc.)
In .env:
verbose- Show everything (default for learning)normal- Show key events onlyminimal- Show only final results
- LangChain Documentation
- LangGraph Concepts
- Multi-Agent Systems
- Plan file with implementation details
This is an educational project. Feel free to:
- Add new architectures
- Improve logging and visualization
- Create new example tasks
- Enhance documentation
- Report issues or suggest improvements
MIT License - feel free to use for learning and teaching.
After mastering these architectures:
- Build your own custom architecture
- Combine patterns for complex workflows
- Add persistence with LangGraph checkpointing
- Implement human-in-the-loop patterns
- Scale to production systems
Happy Learning!
This project demonstrates fundamental multi-agent patterns. Each architecture teaches unique concepts that apply to real-world AI systems.