What Is a Supervisor Agent?
Quick Definition#
A supervisor agent is an AI agent that orchestrates other specialized agents — decomposing complex tasks, delegating work to the most appropriate subagents, monitoring their outputs, and synthesizing results into a coherent response. The supervisor acts as the intelligent controller in hierarchical multi-agent systems, making routing decisions and maintaining overall task coherence that individual subagents cannot provide on their own.
Browse all AI agent terms in the AI Agent Glossary. For the parallel execution the supervisor coordinates, see Agent Swarm. For the delegation mechanism the supervisor uses, see Agent Delegation.
Why Supervisor Agents Exist#
Complex real-world tasks often require capabilities that no single agent has:
- A due diligence task needs: legal research, financial analysis, market research, risk assessment — each requiring different tools and expertise
- A software development task needs: architecture design, code writing, testing, documentation — different specializations
- A content production task needs: research, writing, fact-checking, editing — different skills
Without a supervisor, you would need to manually specify which agent handles each subtask. The supervisor automates this orchestration, using its judgment to break down the goal and assign work to the right agents.
The Supervisor Pattern#
The supervisor pattern follows a standard flow:
User Request → Supervisor
↓ Decompose → Plan [subtask1, subtask2, subtask3]
↓ Dispatch → Agent1(subtask1) || Agent2(subtask2) || Agent3(subtask3)
↓ Monitor → Receive results, check quality
↓ Retry? → If quality insufficient, retry or reassign
↓ Synthesize → Combine results into final output
→ Final Response
Implementing a Supervisor Agent#
Basic Supervisor with LangGraph#
from langgraph.graph import StateGraph, END
from typing import TypedDict, List, Literal
from anthropic import Anthropic
import json
client = Anthropic()
class SupervisorState(TypedDict):
task: str # Original user task
plan: List[str] # Decomposed subtasks
assignments: dict # {subtask: agent_name}
results: dict # {subtask: result}
current_step: int
final_answer: str
# Available specialized agents
AVAILABLE_AGENTS = {
"research_agent": "Searches the web and synthesizes information on topics",
"analysis_agent": "Analyzes data, performs calculations, identifies patterns",
"writing_agent": "Drafts clear, well-structured documents and summaries",
"code_agent": "Writes, reviews, and debugs code"
}
def supervisor_plan(state: SupervisorState) -> dict:
"""Supervisor plans how to break down the task."""
agents_desc = "\n".join([
f"- {name}: {desc}" for name, desc in AVAILABLE_AGENTS.items()
])
response = client.messages.create(
model="claude-opus-4-6", # Supervisor needs strong reasoning
max_tokens=1024,
messages=[{
"role": "user",
"content": f"""You are a supervisor that coordinates specialized agents.
Available agents:
{agents_desc}
Task: {state["task"]}
Create a plan to complete this task by breaking it into subtasks
and assigning each to the most appropriate agent.
Respond as JSON: {{"plan": ["subtask1", ...], "assignments": {{"subtask1": "agent_name", ...}}}}"""
}]
)
data = json.loads(response.content[0].text)
return {
"plan": data["plan"],
"assignments": data["assignments"]
}
def execute_subtask(state: SupervisorState) -> dict:
"""Execute the current subtask using the assigned agent."""
current_idx = state["current_step"]
if current_idx >= len(state["plan"]):
return {}
subtask = state["plan"][current_idx]
agent_name = state["assignments"].get(subtask, "research_agent")
# Build context from prior results
prior_context = ""
if state["results"]:
prior_context = "Prior work:\n" + "\n".join([
f"- {k}: {v[:200]}..." for k, v in state["results"].items()
])
# Execute specialized agent
response = client.messages.create(
model="claude-sonnet-4-6", # Efficient model for execution
max_tokens=1500,
system=f"You are a {agent_name}. {AVAILABLE_AGENTS.get(agent_name, '')}",
messages=[{
"role": "user",
"content": f"""{prior_context}
Subtask: {subtask}
Overall goal: {state["task"]}
Complete this specific subtask with high quality."""
}]
)
result = response.content[0].text
updated_results = {**state["results"], subtask: result}
return {
"results": updated_results,
"current_step": current_idx + 1
}
def supervisor_synthesize(state: SupervisorState) -> dict:
"""Supervisor synthesizes all results into final answer."""
results_text = "\n\n".join([
f"## {subtask}\n{result}"
for subtask, result in state["results"].items()
])
response = client.messages.create(
model="claude-opus-4-6",
max_tokens=2048,
messages=[{
"role": "user",
"content": f"""Original task: {state["task"]}
Results from specialized agents:
{results_text}
Synthesize these results into a comprehensive, well-organized final response."""
}]
)
return {"final_answer": response.content[0].text}
def route_execution(state: SupervisorState) -> Literal["execute", "synthesize"]:
"""Route: execute next subtask or synthesize if all done."""
if state["current_step"] >= len(state["plan"]):
return "synthesize"
return "execute"
# Build supervisor graph
graph = StateGraph(SupervisorState)
graph.add_node("plan", supervisor_plan)
graph.add_node("execute", execute_subtask)
graph.add_node("synthesize", supervisor_synthesize)
graph.set_entry_point("plan")
graph.add_edge("plan", "execute")
graph.add_conditional_edges("execute", route_execution, {
"execute": "execute",
"synthesize": "synthesize"
})
graph.add_edge("synthesize", END)
supervisor_graph = graph.compile()
Supervisor with Quality Control#
Add quality evaluation and retry logic:
def supervisor_quality_check(state: SupervisorState) -> dict:
"""Supervisor evaluates subtask result quality before proceeding."""
if not state["results"]:
return {"quality_approved": True}
last_subtask = state["plan"][state["current_step"] - 1]
last_result = state["results"].get(last_subtask, "")
response = client.messages.create(
model="claude-haiku-4-5-20251001", # Fast model for QC
max_tokens=200,
messages=[{
"role": "user",
"content": f"""Evaluate this subtask result quality (0-10):
Subtask: {last_subtask}
Result: {last_result[:500]}
Respond: {{"score": 0-10, "approved": true/false, "issue": "reason if not approved"}}"""
}]
)
data = json.loads(response.content[0].text)
return {
"quality_approved": data.get("approved", True),
"quality_issue": data.get("issue", "")
}
Supervisor vs Swarm#
The supervisor pattern and swarm pattern are complementary:
| Pattern | Decision Making | Execution | Best For |
|---|---|---|---|
| Supervisor | Intelligent routing | Sequential or parallel | Complex tasks needing judgment |
| Swarm | Mechanical distribution | Parallel | Same operation on many items |
| Supervisor + Swarm | Supervisor decides → spawns swarm | Parallel with oversight | Large-scale complex tasks |
The most powerful architectures combine both: a supervisor breaks down a complex task, then spawns a swarm for any parallel-decomposable subtasks.
Common Misconceptions#
Misconception: The supervisor needs to be a different model The supervisor can use the same model as subagents. What differentiates it is its role and system prompt — focused on planning and synthesis rather than execution. That said, supervisors benefit from more capable models since planning and synthesis require stronger reasoning.
Misconception: Supervisor agents always cost more Because supervisors can route simple subtasks to cheaper, faster models, a well-designed supervisor system often costs less than a single powerful model doing everything. The orchestration overhead is offset by cost savings from specialized routing.
Misconception: Supervisors can handle unlimited subagents Context window limits apply to supervisors too. As subagent results accumulate in the supervisor's context, quality can degrade. Production supervisors use summarization to compress completed subtask results, keeping the supervisor's context focused.
Related Terms#
- Agent Swarm — Parallel execution pattern the supervisor coordinates
- Agent Delegation — The mechanism the supervisor uses to assign work
- Agentic Workflow — Multi-step workflows the supervisor orchestrates
- Agent Loop — The supervisor's own execution cycle
- LangGraph Multi-Agent Tutorial — Tutorial implementing supervisor patterns in LangGraph
- CrewAI vs LangChain — Frameworks with different supervisor/orchestration models
Frequently Asked Questions#
What is a supervisor agent?#
A supervisor agent orchestrates other specialized agents — breaking complex tasks into subtasks, delegating each to the most appropriate agent, monitoring results, and synthesizing everything into a final output. It acts as the intelligent coordinator in hierarchical multi-agent systems.
What does a supervisor agent actually do?#
It performs three functions: task decomposition (breaking complex requests into assignable subtasks), agent dispatch (routing each subtask to the right specialized agent), and result synthesis (combining subagent outputs into a coherent response). It also handles failures by retrying or redirecting when subagents produce insufficient results.
How is a supervisor agent different from a regular agent?#
A regular agent executes tasks using tools like web search or file operations. A supervisor's primary "tool" is other agents. Supervisors use strong reasoning models to plan and synthesize, while directing cheaper, faster models for execution tasks.
When should I use a supervisor pattern vs a flat multi-agent setup?#
Use supervisor when tasks require intelligent decomposition (the breakdown isn't obvious), different subtasks need very different capabilities, or results need critical evaluation before combining. Use flat parallel setups (swarms) when decomposition is mechanical and straightforward, like processing each item in a list identically.