Brain of Multi-Agent Systems: A Deep Dive into Router and Orchestrator Agents
From the publisher’s feed, collected in the ZeroLabs newsroom.
I’ve been building LLM-powered systems for a while now RAG pipelines, Copilot Studio agents, LangGraph workflows and if there’s one thing I’ve learned the hard way, it’s this: the smartest part of a multi-agent system isn’t the most capable model. It’s the thing that decides which model to call.That thing is your Router or Orchestrator agent. Get it wrong and you’ll have expensive, slow, hallucinating pipelines. Get it right and the whole system clicks.Let’s break it down properly.Why Single-LLM Systems Start BreakingWhen you’re prototyping, one model doing everything feels elegant. But push it into a real enterprise workflow and cracks appear fast.Context window degradation As conversation history, tool results, and retrieved chunks pile up, the model’s attention quality over early context visibly drops. Buried facts get forgotten. You’ve probably seen this yourself.Hallucination through overgeneralization A model asked to do legal analysis, SQL generation, and empathetic customer service in a single prompt will average across all three. The output is mediocre at everything. Specialization is the fix.No parallelism, no accountability Complex workflows fan out. A customer query might need a database lookup, a policy check, and a tone classification simultaneously. A single monolithic LLM runs them sequentially in a shared context with compounding errors. And when it goes wrong? You have zero structured trace of why.This is where Routers and Orchestrators come in but before we go further, let’s kill a common confusion.Router vs. Orchestrator: Not the Same ThingThese two terms get used interchangeably and they really shouldn’t.A Router is stateless and single-step. It takes an incoming query, classifies intent, and dispatches it to one downstream handler. That’s it. Think of it as a switchboard operator it doesn’t manage the conversation, it just directs the call.User Query ──► [ROUTER] ──► Agent A ──► Agent B ──► Agent CAn Orchestrator is stateful and dynamic. It decomposes goals, delegates sub-tasks to multiple worker agents, evaluates intermediate results, handles failures, and decides when the job is actually done. It’s running a loop, not making a single decision.User Goal ──► [ORCHESTRATOR: State = {plan, history, results}] ├──► Worker A ──► result ──► Evaluator ├──► Worker B ──► result ──► Evaluator └──► [loop until complete or escalate]Deploying a Router when you need an Orchestrator is like hiring a receptionist to run a hospital.Understand which one your workflow actually needs before writing a line of code.What a Real Orchestrator Is Made OfAn Orchestrator isn’t just a model with a long system prompt. It’s a system with four distinct components working together.The State Manager is your shared workspace a typed schema that every component reads from and writes to. Every intermediate output, plan step, and retry count lives here. It’s also your audit log.The Plan Generator is a high-capability reasoning model (GPT-4o or Claude Sonnet) that analyzes the user goal and produces a structured, JSON-formatted execution plan before any workers are called. This “think before acting” step separates brittle pipelines from robust ones. Force it to emit JSON never free text.Worker Agents are your specialists. Each has a focused system prompt, a curated tool set, and one job. A SQL agent, a web search agent, a summarizer, a RAG retrieval agent each receives only the state slice it needs, does its task, and writes output back. Stateless between calls. Independently testable.The Evaluator / Critic is the most under built component in most systems I’ve reviewed. It’s a separate LLM call that checks each worker output before the Orchestrator moves on completeness, factual grounding, schema compliance. Without it, you’re blindly chaining unverified outputs and calling it agentic AI.The Four Ways to Implement RoutingThere’s a spectrum of techniques, and the right one depends on your latency budget, query complexity, and how much you want to spend per request.1) Static / Deterministic RouterKeyword matching, regex, if/else logic. Zero LLM cost, sub-millisecond latency, fully auditable. Works for narrow, well-defined domains with stable vocabulary. Falls apart on synonyms or anything nuanced. Use it as a first-pass filter in a tiered system, not as your only line of defense.2) Semantic Vector RouterEmbed the user query into a dense vector. Compare against pre-embedded route descriptions using Cosine Similarity. Route to the closest match above a confidence threshold.from sentence_transformers import SentenceTransformerimport numpy as npmodel = SentenceTransformer("all-MiniLM-L6-v2")ROUTES = { "billing_agent": "questions about invoices, payments, charges, and refunds", "support_agent": "technical issues, bugs, errors, and troubleshooting", "sales_agent": "pricing, demos, trials, and plan upgrades",}# Embed routes once at startup not per requestroute_embeddings = { name: model.encode(desc, normalize_embeddings=True) for name, desc in ROUTES.items()}def semantic_router(query: str, threshold: float = 0.45) -> tuple: query_vec = model.encode(query, normalize_embeddings=True) scores = { name: float(np.dot(query_vec, emb)) for name, emb in route_embeddings.items() } best = max(scores, key=scores.get) return (best, scores[best]) if scores[best] >= threshold else ("fallback", scores[best])Handles paraphrasing and natural language variation well. Struggles with multi-intent queries since Cosine Similarity returns a single winner. That threshold parameter needs calibration against real user data don't guess it.3) LLM-as-a-RouterPass the query to a lightweight model (Claude Haiku, GPT-3.5, Gemini Flash) with a function calling schema that forces structured output. This is where you get actual reasoning about intent, not just similarity scores.from typing import List, Literalfrom pydantic import BaseModel, Fieldfrom openai import OpenAI# 1. Initialize the OpenAI clientclient = OpenAI()# 2. Define the schema using Pydantic (Replaces Anthropic's ROUTER_TOOL input_schema)class RouteQuery(BaseModel): route: Literal["billing_agent", "support_agent", "sales_agent", "needs_clarification"] = Field( description="Classify and route the user query to the correct agent." ) detected_intents: List[str] = Field( description="All intents found — including secondary ones." ) confidence: float = Field( description="Confidence score between 0 and 1.", ge=0.0, le=1.0 )def llm_router(query: str) -> dict: # 3. Call the structured completions endpoint response = client.beta.chat.completions.parse( model="gpt-4o-mini", # Lightweight classification model equivalent to Haiku messages=[ {"role": "system", "content": "Intent classifier only. Never answer the user directly."}, {"role": "user", "content": query} ], # Forces the model to respond *only* with the JSON schema structured by your Pydantic class response_format=RouteQuery, max_tokens=256, temperature=0.0 # Kept at 0 for deterministic routing ) # 4. Extract and return the parsed object as a standard python dictionary parsed_output = response.choices[0].message.parsed return parsed_output.model_dump()# --- Example1 Execution ---# result = llm_router("I need to upgrade my plan and look at my last invoice.")# print(result)4) Stateful Supervisor AgentFull graph-based orchestration using LangGraph, AutoGen, or CrewAI. The Supervisor runs in a loop, inspecting full state at every step and deciding the next action dynamically. Not just routing — multi-step planning, parallel execution, retries, and conditional branching. Highest capability, highest cost, highest complexity. Reserve it for workflows that genuinely need it.The Trade-off Table — Be Honest With YourselfMedium doesn’t render Markdown tables, so here it is properly. This is the decision matrix I use when scoping any new agentic system:The Failure Modes No One Warns You AboutHere’s what will find you in production if you don’t find it first. I’ve hit all four of these, in different systems, at different companies.Picking Your Pattern: Day-One ChecklistIf >70% of your queries are predictable and domain-specific start with Semantic Vector + Static fallback. Add LLM routing only for the tail cases. You don’t need a Supervisor for a helpdesk bot.If queries are open-ended, multi-step, or need dynamic re-planning start with a Stateful Supervisor (LangGraph is my go-to), then add cheaper routing tiers as optimization once the system is validated and real usage patterns are visible.Before either: collect 200 real user queries, label them, build an automated routing accuracy test a routing system you can’t measure is a routing system you can’t trust. Run this on every prompt change or model upgrade without exception.The systems you build correctly today become the foundation that more autonomous agents run on tomorrow. Build them with rigor.#Multi-Agent #AI #LLMOps #LangGraph# Agentic AI #AI Architecture #Generative AI #Data Engineering #RAGBrain of Multi-Agent Systems: A Deep Dive into Router and Orchestrator Agents was originally published in Towards AI on Medium, where people are continuing the conversation by highlighting and responding to this story.