Building Multi-Agent Supervisor Systems
Giving a single agent 20 tools degrades its reasoning capabilities. In this lesson, we architect a Multi-Agent Supervisor system: a centralized manager routing subtasks to isolated, specialized worker agents in a clean Hub-and-Spoke topology.
1. Core Mechanics of Supervisor Systems
Select an architecture componentSupervisor Graph Inspector
# 1. SUPERVISOR ROUTING NODE
from typing import Literal
from pydantic import BaseModel, Field
from langchain_openai import ChatOpenAI
members = ["researcher", "coder", "reviewer"]
class RouteResponse(BaseModel):
next_worker: Literal["researcher", "coder", "reviewer", "FINISH"] = Field(
description="The next specialized worker agent to act, or FINISH if done."
)
instructions: str = Field(description="Specific subtask delegated to the worker.")
supervisor_llm = ChatOpenAI(model="gpt-4o", temperature=0)
supervisor_chain = supervisor_llm.with_structured_output(RouteResponse)
def supervisor_node(state: SupervisorState) -> dict:
decision = supervisor_chain.invoke(state["messages"])
return {"next": decision.next_worker, "delegated_task": decision.instructions}2. Interactive Supervisor Agent Studio
Hub-and-Spoke Live SimulationTask:
User Query
Summarize Tesla Q4 2024: revenue, stock move, and analyst sentiment.
Common Engineering Traps
If Worker A produces an ambiguous observation, the Supervisor might delegate back to Worker B, who delegates back to Worker A. Enforce a hard ceiling on recursion_limit (e.g. 15 turns) to prevent token-draining ping-pong cycles.
Never give the supervisor direct tool access. If the manager can query search itself, it frequently gets lazy, attempts to do all work directly, and bypasses the worker specialists entirely. The supervisor must ONLY orchestrate.
Key Architectural Takeaways
- 1.Hub-and-Spoke Efficiency: Centralized routing avoids peer-to-peer network complexity and maintains clean message history.
- 2.Cognitive Specialization: Restricting workers to 3-5 tools ensures high tool selection precision.
- 3.Independent Scalability: Specialist agents can use different models (e.g. gpt-4o-mini for scraping, gpt-4o for code generation) to optimize cost and latency.
Building Multi-Agent Swarm Systems
What happens when there is no manager? Discover OpenAI-style Swarm architectures: decentralized agent handoffs where agents pass conversations directly to peers.