Multi-Agent Consultation and Global Routing: A Practical Configuration Guide
This guide explains how to combine multi-agent consultation (Mixture of Agents) with global routing to improve the stability of AI assistant applications. It covers a two-layer role design in which reference agents only generate structured perspectives without tool access, while a single aggregator holds the tools and produces executable results. It also presents a practical routing table, routing principles for read-only, reversible, and irreversible tasks, a six-step rollout process, configuration examples, tuning techniques, and a troubleshooting reference.
1. The Problem: Limits of a Single-Model Architecture
When building AI assistant applications, the most common issue is not that the model is not strong enough. It is that a single model is not stable enough on long, multi-step tasks. This shows up in three typical ways:
- Fixed reasoning paths: When a model reasons continuously within the same context, it tends to follow the first assumption it forms all the way to the end, with no mechanism for challenging itself.
- Hallucination and factual drift: Without cross-checking, the model fills information gaps with details that look plausible but cannot be verified.
- Incomplete solutions: Complex tasks usually span technical feasibility, boundary conditions, cost, and maintainability at the same time, and a single generation pass struggles to cover all of them.
The core idea of multi-agent consultation (Mixture of Agents, or MoA) is to split “divergence” and “convergence” into two separate stages: multiple perspectives generate candidate views in parallel, and then a single decision maker performs cross-validation and drives execution. This is similar to the layered “generate-review-revise” approach common in the industry, but it places more emphasis on strong isolation of permissions and responsibilities.
2. Layered Role Design: The Advisory Group and the Decision Executor
2.1 Reference Models (The Advisory Group)
The reference layer is responsible only for “thinking”, not for “doing”. Reasonable constraints include:
- Keep the count to 2-3, with orthogonal perspectives (for example: architecture feasibility, risk and boundaries, cost and operations);
- Grant no tool permissions; reading or writing files, executing commands, and accessing the network are all prohibited;
- Output is strictly limited to structured perspectives, not final answers.
An illustrative output contract (it can be carried in any structured format):
{"perspective": "risk","key_assumptions": ["..."],"proposed_approach": ["..."],"blind_spots": ["..."],"confidence": 0.0}
This design brings two direct benefits: first, divergence stays controllable because the perspectives do not overlap; second, cost is very low, because the reference layer can use lightweight models and is inherently unable to cause side effects.
2.2 The Aggregator Model (The Decision Executor)
The aggregation layer is the only role that holds full tool permissions. It reads the full context, consolidates the candidate perspectives, cross-validates them, fixes gaps, and outputs an executable result. Its key constraint is uniqueness: if there are two executors with write access, their operations will overwrite each other and leave state inconsistent.
Recommended processing order for the aggregation stage:
- Align the shared conclusions across the reference perspectives (high-confidence consensus);
- Flag conflicting items and give the rationale for each decision;
- Explicitly downgrade assertions that cannot be verified to “assumptions to be confirmed”;
- Produce and execute the final plan while keeping a rollback path.
3. Global Routing Configuration: Sending Requests to the Right Role
Global routing decides “who handles a request, and in what order”. A routing table that can be put into practice contains the following fields:
| Field | Meaning | Suggested policy |
|---|---|---|
| task_type | Task category | Factual Q&A / code generation / change operation / analysis and review |
| risk_level | Risk level | Read-only, reversible write, irreversible write |
| need_tools | Whether tools are needed | Determines whether the request can enter the execution stage |
| route_mode | Routing mode | Single-model direct answer / consultation mode |
| fallback | Fallback path | Fall back to a single model when consultation fails, and mark it |
The core principle of routing decisions: only read-only or reversible tasks are allowed to execute automatically; irreversible write operations must include a human confirmation step. Illustrative logic:
if risk_level == "irreversible":route_mode = "single_with_confirmation"elif need_tools and task_type in ("refactor", "migration"):route_mode = "moa"else:route_mode = "single"
In terms of deployment, the routing layer is usually a stateless component. Session state and tool execution state are kept separately in a cache and in persistent storage, which makes horizontal scaling and failure recovery easier. Logs and call traces are sent to a unified logging service and monitoring and alerting system, forming an observable closed loop.
4. Rollout Configuration Process (Six Steps)
- Define task categories and risk levels: Split business scenarios into a limited set of categories first, to avoid routing rules growing out of control.
- Determine the perspective matrix: Assign 2-3 orthogonal perspectives to each task category, and put them in configuration rather than hard-coding them in prompts.
- Configure permission boundaries: The reference layer gets zero tool permissions; the aggregation layer is granted least privilege, with write scope limited to specified directories or resource prefixes.
- Set budgets and timeouts: Set output length limits and timeouts for the reference layer, so a single point cannot slow down overall latency.
- Build an evaluation set: Prepare 30-100 samples with reference answers or acceptance criteria, covering normal, boundary, and adversarial inputs.
- Canary release and rollback: Enable consultation mode on a small traffic share first, compare pass rate and average latency against the single-model baseline, then gradually increase the share.
Configuration example (structural illustration, not a specific product API):
route:default_mode: singlerules:- match: { task_type: "code_change", risk_level: "reversible" }mode: moareferences:- { role: architecture, model_class: large }- { role: risk, model_class: small }- { role: cost, model_class: small }aggregator: { role: executor, tools: [fs_read, fs_write, shell] }budget: { max_rounds: 1, timeout_ms: 20000 }- match: { risk_level: "irreversible" }mode: single_with_confirmation
5. Advanced Tuning Techniques
- Deduplicate perspectives: Periodically measure how much each reference perspective overlaps with the final conclusion. A perspective whose overlap stays consistently high should be replaced; otherwise you are just paying twice for the same thing.
- Prefer a single round: In most cases, “one round of consultation plus one aggregation” is enough. Enable multiple rounds only when evaluation shows a clear benefit.
- Weight by confidence: Have the aggregation layer make decisions by confidence rather than average voting, so low-quality views do not dilute the conclusion.
- Prefer structure over free text: Constraining the output fields of the reference layer significantly reduces parsing ambiguity for the aggregation layer.
- Make cost observable: Track call volume, latency, and failure rate separately by routing mode; only then can you judge the real cost-effectiveness of consultation mode.
- Safety fallback: For irreversible operations, enforce “produce the plan first, review after execution”, and keep snapshots or backups for rollback.
6. Common Failures and Troubleshooting
| Symptom | Common cause | How to handle it |
|---|---|---|
| Latency rises significantly | Reference layer timeouts or too many rounds | Tighten timeouts, drop to a single round, reduce the number of perspectives |
| Contradictory conclusions | Conflicting items are not explicitly resolved | Require the rationale for each decision in the aggregation contract |
| Inconsistent execution results | Multiple executors writing concurrently | Converge to a single aggregation executor and add locking |
| Hallucination does not drop | Reference perspectives are highly homogeneous | Restructure the perspective matrix and add risk and cost dimensions |
| Cost exceeds budget | Everything goes through consultation mode | Tighten routing match conditions and enable it only for complex tasks |
7. Conclusion
The essence of multi-agent consultation and global routing is trading separation of responsibilities for result stability: the reference layer handles divergence with zero permissions, the aggregation layer handles convergence as the sole executor, and the routing layer matches requests to an appropriate and safe working mode. In general engineering practice on cloud platforms such as Baidu AI Cloud, this kind of layered architecture is usually implemented together with common capabilities such as object storage, message queues, container platforms, and monitoring and alerting, so that you get observable, rollback-capable, and scalable delivery quality while keeping security boundaries intact.
