From deepagents-skills
Implements multi-agent coordination patterns (supervisor-subagent, router, orchestrator-worker, handoffs) for LangGraph apps, including state schemas and debugging.
npx claudepluginhub lubu-labs/langchain-agent-skills --plugin langgraph-skillsThis skill uses the workspace's default tool permissions.
Implement and configure multi-agent coordination patterns for LangGraph applications.
assets/examples/handoff-example/js/index.jsassets/examples/handoff-example/js/package.jsonassets/examples/handoff-example/python/graph.pyassets/examples/handoff-example/python/requirements.txtassets/examples/orchestrator-example/js/index.jsassets/examples/orchestrator-example/js/package.jsonassets/examples/orchestrator-example/python/graph.pyassets/examples/orchestrator-example/python/requirements.txtassets/examples/router-example/js/index.jsassets/examples/router-example/js/package.jsonassets/examples/router-example/python/graph.pyassets/examples/router-example/python/requirements.txtassets/examples/supervisor-example/js/index.jsassets/examples/supervisor-example/js/package.jsonassets/examples/supervisor-example/python/graph.pyassets/examples/supervisor-example/python/requirements.txtreferences/handoffs.mdreferences/orchestrator-worker.mdreferences/pattern-comparison.mdreferences/router-pattern.mdGuides Next.js Cache Components and Partial Prerendering (PPR) with cacheComponents enabled. Implements 'use cache', cacheLife(), cacheTag(), revalidateTag(), static/dynamic optimization, and cache debugging.
Guides building MCP servers enabling LLMs to interact with external services via tools. Covers best practices, TypeScript/Node (MCP SDK), Python (FastMCP).
Generates original PNG/PDF visual art via design philosophy manifestos for posters, graphics, and static designs on user request.
Implement and configure multi-agent coordination patterns for LangGraph applications.
Choose the right pattern based on your coordination needs:
| Pattern | Best For | When to Use |
|---|---|---|
| Supervisor | Complex workflows, dynamic routing | Agents need to collaborate, routing is context-dependent |
| Router | Simple categorization, independent tasks | One-time routing, deterministic decisions |
| Orchestrator-Worker | Parallel execution, high throughput | Independent subtasks, results need aggregation |
| Handoffs | Sequential workflows, context preservation | Clear sequence, each agent builds on previous |
Quick Decision:
For detailed comparison: See references/pattern-comparison.md
Overview: Central coordinator delegates to specialized subagents based on context.
Quick Start:
# Generate supervisor graph boilerplate
uv run scripts/generate_supervisor_graph.py my-team \
--subagents "researcher,writer,reviewer"
# TypeScript
uv run scripts/generate_supervisor_graph.py my-team \
--subagents "researcher,writer,reviewer" \
--typescript
Key Components:
next field for routing decisionsExample Flow:
User Request → Supervisor → Researcher → Supervisor → Writer → Supervisor → FINISH
For complete implementation: See references/supervisor-subagent.md
Overview: One-time routing to specialized agents based on initial request.
Key Components:
Example Flow:
User Request → Router → Sales Agent → END
├→ Support Agent → END
└→ Billing Agent → END
Routing Strategies:
For complete implementation: See references/router-pattern.md
Overview: Decompose task into parallel subtasks, aggregate results.
Key Components:
Send(...) objects from conditional edges and use a list reducer (for example Annotated[list[dict], operator.add]) so worker outputs accumulateExample Flow:
Task → Orchestrator → Worker 1 ┐
→ Worker 2 ├→ Aggregator → Result
→ Worker 3 ┘
Best Practices:
For complete implementation: See references/orchestrator-worker.md
Overview: Sequential agent handoffs with context preservation.
Key Components:
Example Flow:
Request → Researcher → Writer → Editor → FINISH
(with context preservation)
Handoff Strategies:
For complete implementation: See references/handoffs.md
Runnable mini-projects (Python + JavaScript):
assets/examples/supervisor-example/assets/examples/router-example/assets/examples/orchestrator-example/assets/examples/handoff-example/Each pattern requires specific state schema design:
Supervisor Pattern:
class SupervisorState(TypedDict):
messages: Annotated[list[BaseMessage], add_messages]
next: Literal["agent1", "agent2", "FINISH"]
current_agent: str
Router Pattern:
class RouterState(TypedDict):
messages: list[BaseMessage]
route: Literal["category1", "category2"]
Orchestrator-Worker:
import operator
class OrchestratorState(TypedDict):
task: str
subtasks: list[dict]
results: Annotated[list[dict], operator.add]
Handoffs:
class HandoffState(TypedDict):
messages: Annotated[list[BaseMessage], add_messages]
next_agent: str
context: dict
For detailed state patterns: See references/state-management-patterns.md
# Validate agent graph for issues
uv run scripts/validate_agent_graph.py path/to/graph.py:graph
# Checks for:
# - Unreachable nodes
# - Cycles without termination
# - Dead ends
# - Invalid routing
# Generate Mermaid diagram
uv run scripts/visualize_graph.py path/to/graph.py:graph --output diagram.md
# View in browser or IDE with Mermaid support
1. Clear Agent Responsibilities
2. Loop Prevention
3. Context Management
4. Error Handling
1. Over-Supervision
# ❌ Bad: Supervisor for simple linear flow
User → Supervisor → Agent1 → Supervisor → Agent2 → Supervisor
# ✅ Good: Use handoffs instead
User → Agent1 → Agent2 → FINISH
2. Complex Router Logic
# ❌ Bad: Complex routing rules in router
if complex_condition_A and (condition_B or condition_C):
route = determine_complex_route()
# ✅ Good: Use supervisor with LLM
route = llm.invoke("Analyze and route: {query}")
3. Unmanaged State Growth
# ❌ Bad: Accumulating all messages forever
messages: list[BaseMessage] # Grows unbounded
# ✅ Good: Summarize or limit
if len(messages) > 20:
messages = summarize_context(messages)
Use LangSmith to visualize agent interactions:
import os
os.environ["LANGSMITH_TRACING"] = "true"
os.environ["LANGSMITH_API_KEY"] = "<your-api-key>"
os.environ["LANGSMITH_PROJECT"] = "multi-agent-debug"
result = graph.invoke(input_state)
Add logging to routing nodes:
def supervisor_node(state: SupervisorState) -> dict:
decision = make_routing_decision(state)
print(f"Supervisor routing to: {decision}")
print(f"Current state: {len(state['messages'])} messages")
print(f"Iteration: {state.get('iteration', 0)}")
return {"next": decision}
# Detect common issues
uv run scripts/validate_agent_graph.py my_agent/graph.py:graph
# Check for:
# - Unreachable nodes
# - Infinite loops
# - Dead ends
# Generate diagram
uv run scripts/visualize_graph.py my_agent/graph.py:graph -o flow.md
Supervisor Pattern:
Router Pattern:
Orchestrator-Worker:
Handoffs:
Token Usage:
LLM Calls:
Pattern Selection:
def test_supervisor_routing():
"""Test supervisor routes correctly."""
state = {
"messages": [HumanMessage(content="Need research")],
"next": "",
"current_agent": ""
}
result = supervisor_node(state)
assert result["next"] == "researcher"
def test_full_workflow():
"""Test complete multi-agent workflow."""
graph = create_supervisor_graph()
result = graph.invoke({
"messages": [HumanMessage(content="Write article about AI")]
})
# Verify agents were called in correct order
assert "researcher" in result["agent_history"]
assert "writer" in result["agent_history"]
# Validate before deployment
python3 scripts/validate_agent_graph.py graph.py:graph
When routing logic becomes complex:
# Before: Complex router
def route(query):
if complex_rules(query):
return category
# After: Supervisor with LLM
def supervisor(state):
return llm_routing_decision(state)
When need dynamic routing:
# Before: Fixed sequence
Agent1 → Agent2 → Agent3
# After: Dynamic routing
Supervisor ⇄ Agent1/Agent2/Agent3
When tasks become independent:
# Before: Sequential
Agent1 → Agent2 → Agent3
# After: Parallel
Orchestrator → [Agent1, Agent2, Agent3] → Aggregator
Pattern: Router + Supervisor
Router → Sales Supervisor → Sales Agents
↓
Support Supervisor → Support Agents
Pattern: Supervisor or Handoffs
Supervisor ⇄ Researcher
⇄ Writer
⇄ Editor
Pattern: Orchestrator-Worker
Orchestrator → Data Collectors → Aggregator
Pattern: Orchestrator-Worker + Supervisor
Router → PDF Orchestrator → Workers → Aggregator
↓
DOCX Orchestrator → Workers → Aggregator
Generate supervisor-subagent boilerplate:
uv run scripts/generate_supervisor_graph.py <name> [options]
Options:
--subagents AGENTS Comma-separated list (default: researcher,writer,reviewer)
--output DIR Output directory (default: current directory)
--typescript Generate TypeScript instead of Python
Validate graph structure:
uv run scripts/validate_agent_graph.py <module_path>
Format: path/to/module.py:graph_name
Checks:
- Unreachable nodes
- Cycles
- Dead ends
- Invalid routing
Generate Mermaid diagrams:
uv run scripts/visualize_graph.py <module_path> [options]
Options:
--output FILE Output file (default: stdout)
--diagram-only Skip documentation, output diagram only
Check:
Solutions:
Solutions:
Solutions:
Solutions:
Pattern Details:
State Management: references/state-management-patterns.md
Pattern Comparison: references/pattern-comparison.md
Working Examples: assets/examples/
LangGraph Documentation: