Mixture of Agents (MoA) and Global Routing: A Practical Guide from Basic Setup to Advanced Configuration
Learn how to structure a Mixture of Agents (MoA) workflow with advisory models and a tool-enabled primary model. This guide covers a basic static configuration, global routing based on task complexity and risk, and practical techniques for managing conflicting advice, latency, and observability.
1. What Is a Mixture of Agents Workflow?
MoA (Mixture of Agents) combines collaborative reasoning across multiple models with centralized decision-making and execution. Its core principle is simple: multiple models contribute perspectives; one model makes the final decision.
Development teams often face two challenges:
- A single large language model may have strong general capabilities but produce fluent yet incorrect responses in specialized areas such as code review, legal analysis, or financial data interpretation.
- Letting multiple agents debate freely can lead to repetitive arguments, unpredictable outputs, and excessive token consumption—without improving the final answer.
The MoA workflow described here offers a middle ground. Multiple models analyze a task in parallel, then a primary model with tool permissions consolidates their advice, removes duplication, corrects errors, and produces the final output. This “diverge, then converge” structure balances output quality with operational predictability.
2. Core Roles: Advisory Models and the Primary Model
A typical MoA consultation workflow has two roles. Their responsibilities must remain clearly separated to prevent collaboration from turning into uncontrolled agent interaction.
Advisory Models
The advisory group typically consists of two or three models with complementary strengths. These can be lightweight or larger models; complementary expertise matters more than model count.
For example, the group might include:
- A model specializing in logical reasoning and mathematics.
- A model specializing in long-context comprehension and information extraction.
- A model specializing in domain knowledge, such as coding standards or industry terminology.
Advisory models follow three constraints:
- No tool permissions. They cannot search, execute code, read or write files, or use other external capabilities. Their role is limited to reasoning and analysis.
- No final user-facing answer. Their outputs are recommendations for the primary model, not final responses to the user.
- Structured output. A fixed format, such as “Conclusion / Evidence / Risks,” makes their advice easier to aggregate. Here, “Conclusion” means an advisory assessment rather than the final decision.
Primary Model
The primary model is the only model authorized to use tools. It is responsible for:
- Reading and cross-checking all advisory outputs.
- Resolving disagreements, either by requesting revised analysis or making its own assessment.
- Calling external tools to complete the task, including searches, file operations, and code execution.
- Producing the final user-facing answer.
Choose a model with strong overall capabilities for this role, since it is responsible for final output quality.
3. Basic Setup: Start with Static Routing
For an initial implementation, use a simple two-layer configuration with static routing. Establish a working workflow before adding optimization.
The following YAML illustrates the configuration structure:
mode: moarouter:type: static # Static routing: all tasks use the same consultation workflowmain_agent: primary # Primary modelreference_agents:- ref_reasoning # Reasoning specialist- ref_domain # Domain specialistagents:primary:tools: [search, code_exec, file_io] # The primary model has all tool permissionsref_reasoning:tools: [] # Advisory models have no tool permissionsoutput_format: conclusion+evidence+riskref_domain:tools: []output_format: conclusion+evidence+risk
Keep these points in mind:
- Do not start with more than three advisory models. Two can already improve answer quality, while additional models increase aggregation costs and latency.
- Call advisory models in parallel, not sequentially. This avoids adding their individual response times together and helps keep the advisory phase close to a single-model call.
- Test on a fixed task type first. Code explanation or document summarization are useful starting points. Expand to other scenarios after the workflow is stable.
4. Advanced Setup: Introduce Global Routing
Static routing applies the same workflow to every request. Even simple questions trigger a full consultation, wasting resources.
A global routing layer addresses this limitation by deciding whether a task needs consultation and how many advisory models to involve.
Routing Strategy
The routing layer is essentially a lightweight classifier, implemented with rules or a small model. It can divide incoming requests into categories:
- Simple tasks, such as casual conversation or straightforward queries: the primary model answers directly, without consultation.
- Moderate tasks, such as general analysis: one advisory model provides a cross-check.
- Complex tasks, such as high-risk decisions or specialized domain questions: two or three advisory models participate in a full consultation.
An illustrative routing rule:
def route(task):if task.complexity == "low":return [main_agent]if task.domain in HIGH_RISK_DOMAINS or task.complexity == "high":return [main_agent, ref_reasoning, ref_domain]return [main_agent, ref_reasoning]
Routing Criteria
Useful routing dimensions include:
- Task type: generation, analysis, or decision-making.
- Risk level: tasks involving irreversible or consequential actions, such as executing deletion commands or submitting code, should require full consultation.
- Context length: tasks with very long inputs should prioritize advisory models with strong long-context capabilities.
- Historical performance: if consultation consistently produces results that differ little from single-model outputs for a task category, route those tasks through a simpler workflow to reduce costs.
Risk-based escalation should take precedence over a low-complexity classification when designing the routing rules.
5. Advanced Techniques and Common Pitfalls
Resolve Disagreements Explicitly
When advisory models disagree, do not simply use majority voting. The primary model should identify the points of disagreement and resolve each one. If necessary, request an additional round of targeted analysis.
Limit Advisory Output Length
Set a short output limit for advisory models to prevent excessive context growth during aggregation. The source workflow suggests a limit of roughly 300 characters; the key is to keep recommendations concise and structured.
Budget for Latency
Consultation latency is approximately:
Slowest advisory model response time + aggregation time
Selecting advisory models with similar response times can help avoid one model becoming a persistent bottleneck.
Keep Advisory Models Within Their Role
State explicitly in their prompts that outputs are for internal reference only. This reduces the likelihood that advisory models will write as though they are delivering the final answer to the user.
Make the Workflow Observable
For each consultation, record the original advisory outputs and how the primary model used them. These records support audits and configuration tuning.
Cloud logging, monitoring, and alerting services can also help teams identify the causes of declining output quality more quickly.
6. Conclusion
MoA uses controlled model collaboration to improve answer quality. Global routing determines when that collaboration is worth its additional cost.
A practical implementation path is to:
- Establish a working two-layer workflow with static routing.
- Add routing classification to optimize resource usage.
- Use logs and observed results to refine routing rules over time.
For production deployments, this architecture can be combined with cloud container platforms, logging services, monitoring, and alerting to build an observable and maintainable multi-agent system.
