LangGraph Multi-Agent Supervisor Skill
Build LangGraph multi-agent systems with a supervisor that orchestrates specialized worker agents. The supervisor intelligently routes user queries to the appropriate agent and manages the overall conversation flow.
Core Architecture
- Supervisor node: LLM-powered routing that selects the best worker agent for each query
- Worker agents: Specialized agents (Genie, RAG, MCP, custom) that handle domain-specific tasks
- State management: Shared state across agents with result aggregation
- Routing strategies: LLM-based (semantic), rule-based (keywords), sequential, or parallel
Supervisor Patterns
Choose the right pattern based on your use case:
| Pattern |
Use Case |
Pros |
Cons |
| Simple |
Single agent selection per query |
Easy to implement |
No multi-step workflows |
| Hierarchical |
Complex domains with sub-domains |
Scalable organization |
More complex setup |
| Sequential |
Multi-step workflows |
Results build on each other |
Slower execution |
| Parallel |
Independent queries needing multiple agents |
Faster execution |
More complex aggregation |
See references/patterns.md for complete implementation code for all 4 patterns.
Worker Agent Types
| Type |
Description |
Key Config |
| Genie |
Natural language queries against Databricks Genie spaces |
space_id |
| RAG |
Document retrieval via Vector Search |
index_name, endpoint_name |
| MCP |
External tool execution via MCP protocol |
tools list |
| LLM |
General-purpose LLM responses |
model endpoint |
| Custom |
Any custom function |
User-defined |
See references/worker-agents.md for implementation code and configuration-driven agent creation.
Quick Start
1. Define State and Workers
from typing import TypedDict, Annotated, Sequence
import operator
from langchain_core.messages import BaseMessage, AIMessage
from langgraph.graph import StateGraph, END
from databricks_langchain import ChatDatabricks
class SupervisorState(TypedDict):
messages: Annotated[Sequence[BaseMessage], operator.add]
next_agent: str
agent_results: dict
final_response: str
WORKER_AGENTS = {
"sales_agent": {"description": "Sales data queries", "type": "genie", "space_id": "..."},
"docs_agent": {"description": "Documentation search", "type": "rag", "index_name": "..."},
}
2. Build Graph
graph = StateGraph(SupervisorState)
graph.add_node("supervisor", supervisor_node)
for name, config in WORKER_AGENTS.items():
graph.add_node(name, create_worker_node(name, config))
graph.add_edge(name, END)
graph.set_entry_point("supervisor")
graph.add_conditional_edges("supervisor", route_to_agent, routes)
agent = graph.compile()
3. Enable MLflow Tracking
import mlflow
mlflow.langchain.autolog()
supervisor = create_supervisor_agent()
Best Practices
- Agent design: Keep agents focused and specialized with clear descriptions for routing
- Routing: Use semantic routing (LLM) for flexibility, add rule-based for known patterns
- State: Keep shared state minimal, use agent-specific state for details
- Performance: Cache results, use parallel execution when possible, implement timeouts
- Observability: Enable MLflow tracing, log routing decisions, track execution time
References
1---2name: langgraph-multi-agent-supervisor3description: Build LangGraph multi-agent systems with intelligent supervisor orchestration of specialized worker agents (Genie, RAG, MCP, LLM, custom). Use when creating multi-agent systems, implementing supervisor patterns, routing queries to specialized agents, or building hierarchical/sequential/parallel agent workflows.4---56# LangGraph Multi-Agent Supervisor Skill78Build LangGraph multi-agent systems with a supervisor that orchestrates specialized worker agents. The supervisor intelligently routes user queries to the appropriate agent and manages the overall conversation flow.910## Core Architecture1112- **Supervisor node**: LLM-powered routing that selects the best worker agent for each query13- **Worker agents**: Specialized agents (Genie, RAG, MCP, custom) that handle domain-specific tasks14- **State management**: Shared state across agents with result aggregation15- **Routing strategies**: LLM-based (semantic), rule-based (keywords), sequential, or parallel1617## Supervisor Patterns1819Choose the right pattern based on your use case:2021| Pattern | Use Case | Pros | Cons |22|---------|----------|------|------|23| Simple | Single agent selection per query | Easy to implement | No multi-step workflows |24| Hierarchical | Complex domains with sub-domains | Scalable organization | More complex setup |25| Sequential | Multi-step workflows | Results build on each other | Slower execution |26| Parallel | Independent queries needing multiple agents | Faster execution | More complex aggregation |2728See [references/patterns.md](references/patterns.md) for complete implementation code for all 4 patterns.2930## Worker Agent Types3132| Type | Description | Key Config |33|------|-------------|------------|34| Genie | Natural language queries against Databricks Genie spaces | `space_id` |35| RAG | Document retrieval via Vector Search | `index_name`, `endpoint_name` |36| MCP | External tool execution via MCP protocol | `tools` list |37| LLM | General-purpose LLM responses | `model` endpoint |38| Custom | Any custom function | User-defined |3940See [references/worker-agents.md](references/worker-agents.md) for implementation code and configuration-driven agent creation.4142## Quick Start4344### 1. Define State and Workers4546```python47from typing import TypedDict, Annotated, Sequence48import operator49from langchain_core.messages import BaseMessage, AIMessage50from langgraph.graph import StateGraph, END51from databricks_langchain import ChatDatabricks5253class SupervisorState(TypedDict):54 messages: Annotated[Sequence[BaseMessage], operator.add]55 next_agent: str56 agent_results: dict57 final_response: str5859WORKER_AGENTS = {60 "sales_agent": {"description": "Sales data queries", "type": "genie", "space_id": "..."},61 "docs_agent": {"description": "Documentation search", "type": "rag", "index_name": "..."},62}63```6465### 2. Build Graph6667```python68graph = StateGraph(SupervisorState)69graph.add_node("supervisor", supervisor_node)70for name, config in WORKER_AGENTS.items():71 graph.add_node(name, create_worker_node(name, config))72 graph.add_edge(name, END)7374graph.set_entry_point("supervisor")75graph.add_conditional_edges("supervisor", route_to_agent, routes)76agent = graph.compile()77```7879### 3. Enable MLflow Tracking8081```python82import mlflow83mlflow.langchain.autolog()84supervisor = create_supervisor_agent()85```8687## Best Practices88891. **Agent design**: Keep agents focused and specialized with clear descriptions for routing902. **Routing**: Use semantic routing (LLM) for flexibility, add rule-based for known patterns913. **State**: Keep shared state minimal, use agent-specific state for details924. **Performance**: Cache results, use parallel execution when possible, implement timeouts935. **Observability**: Enable MLflow tracing, log routing decisions, track execution time9495## References9697- [references/patterns.md](references/patterns.md) - Complete implementations of all 4 supervisor patterns98- [references/worker-agents.md](references/worker-agents.md) - Worker agent implementations and config-driven creation99- [examples/example_agents.json](examples/example_agents.json) - Example agent configurations100- Databricks Multi-Agent Framework: https://docs.databricks.com/generative-ai/agent-framework/multi-agent-genie101- LangGraph Supervisor: https://github.com/langchain-ai/langgraph-supervisor-py