Multi-Agent Architecture with Multimodal Models: A Practical Guide to Roles, Contracts, and Verification
This article explains why relying on a single all-purpose model tends to break down in multi-agent workflows, and how to fix it with role design. It introduces a three-layer structure of Manager, Executor, and Human, shows how to define minimal task contracts with acceptance criteria and budgets, and describes capability routing that reserves heavy reasoning for the steps that need it. It also covers sandboxed execution with least privilege, a three-gate acceptance loop, observability and cost governance metrics, common anti-patterns, and a practical implementation checklist. The approach is model-agnostic and can run on general cloud capabilities such as container platforms, message queues, object storage, and monitoring.
1. The Starting Problem: Why “One Capable Model for Everything” Fails
When building a multi-agent workflow, a common initial assumption is that picking the single most capable model will let it handle every stage. In practice, three problems tend to show up.
First, capability is unevenly distributed. The same model may excel at natural language organization and clarifying vague requirements, yet become less stable on long chains of logical reasoning and complex code module generation. Conversely, execution-oriented models are often poor at back-and-forth alignment with people.
Second, cost and latency get averaged out. Simple tasks (rewording a paragraph, writing a short explanation) are forced through the heaviest reasoning path, driving up both token consumption and response time.
Third, permission and risk boundaries blur. When one agent both faces the user and executes code and file operations directly in the main environment, a single misjudgment can pollute the workspace.
The conclusion is not that “the model isn’t strong enough,” but that the role design is wrong. A more reasonable approach is to model explicitly who communicates, who does the work, and who makes the final call. That is exactly where a multi-agent architecture adds value.
2. Role Abstraction: A Three-Layer Manager / Executor / Human Structure
The architecture can be abstracted into three layers, each carrying only one class of responsibility.
- Manager (coordination layer): faces the human, clarifies vague requirements, decomposes tasks, builds plans, aggregates results, and “translates” between sides. Its core capabilities are context understanding, multimodal input understanding (screenshots, tables, drawings), and clarity of expression.
- Executor (execution layer): faces the task, runs in an isolated environment, receives structured subtasks, and produces code, scripts, configurations, or data results. Its core requirements are logical rigor, reproducibility, and rollback on failure.
- Human (decision layer): does only three things — confirms boundaries, clicks the mouse, makes trade-offs.
The key constraint of this split: the Manager does not modify the production workspace directly, and the Executor does not face the user directly. All cross-layer interaction must go through a structured contract.
3. Task Contracts: Making Dispatch Verifiable Instead of “Verbal Relay”
The most common cause of multi-agent failure is not model capability but vague subtask descriptions. Define a minimal contract for each subtask:
{"task_id": "T-1024","goal": "Add idempotent write logic to the order module","context_refs": ["repo://order/service", "doc://api/contract#v2"],"constraints": ["Do not change public interface signatures", "Explain any new dependencies"],"acceptance": ["All unit tests pass", "Repeated requests produce no duplicate records"],"sandbox": {"fs": "ephemeral", "network": "deny"},"budget": {"max_turns": 12, "max_tokens": 60000}}
The most important fields are acceptance and budget. The former turns “did it well” into a decidable condition; the latter keeps the execution layer from falling into infinite retries. The Manager only generates contracts and evaluates acceptance results; it does not get involved in implementation details.
4. Load on Demand: Reserve Heavy Reasoning for the Steps That Need It
The most valuable observation in the original discussion is “load on demand.” In engineering terms, this can be implemented as capability routing: run a lightweight classification first, then decide which path to take.
def route(msg, ctx):# Lightweight check: does this need isolated execution?if needs_code_execution(msg) or ctx["complexity"] >= 3:return "executor"if needs_visual_understanding(msg):return "multimodal_path"return "chat_path" # low latency, low consumption
The trade-off logic across the three paths:
- chat_path: everyday Q&A, document writing, requirement clarification, optimized for low latency;
- multimodal_path: handles inputs such as screenshots, UI mockups, and scanned documents, first converting unstructured information into a structured description;
- executor: anything involving code, scripts, or batch data processing, executed inside a sandbox.
The payoff is that the cost curve is tiered by task difficulty, rather than every request paying the same price.
5. Isolated Execution and Least Privilege
The execution layer must default to no network, an ephemeral filesystem, and exposure of only the minimum directories needed to finish the task. Three principles are recommended:
- Least privilege: grant only the necessary read/write scope, and do not mount global credentials;
- Rollback-ready: produce all changes as patches, and let the upper layer decide whether to merge;
- Full traceability: write commands, exit codes, durations, and artifact summaries to a logging service for auditing.
A sketch of the flow:
Manager generates the contract↓Scheduler writes the task to a queue (message queue for peak shaving)↓Executor runs inside a sandbox spun up by the container platform↓Produces patch + execution report → archived to object storage↓Manager verifies against acceptance → Human decides
6. The Acceptance Loop: A Quality Gate for Multi-Agent Systems
A multi-agent system without an acceptance stage simply amplifies uncertainty. Three gates are recommended:
- Static gate: format, types, and static checks all pass;
- Dynamic gate: unit tests and key-path integration tests pass;
- Semantic gate: the Manager checks the original requirements item by item and outputs “satisfied / not satisfied / needs human confirmation.”
Only when all three gates are green is the result allowed to move up to the decision layer. If two consecutive rounds fail, a fallback strategy should trigger: reduce task granularity, or hand off to a human.
7. Observability and Cost Governance
Multi-agent chains are harder to troubleshoot than a single model call, so the following metrics should become a standing dashboard (implementable on top of logging and monitoring/alerting capabilities):
- Routing distribution: the share of each of the three paths, to judge whether there is over-dispatch;
- Tokens and latency per task: to locate high-consumption stages;
- First-pass rate: the proportion passing the acceptance gates on the first round, which directly reflects contract quality;
- Human intervention rate: the lower it is, the higher the degree of automation.
Governance measures include setting a smaller context window for chat_path, caching results for repeated tasks, and setting a concurrency cap for the execution layer.
8. Common Anti-Patterns
- Role bleed: letting the coordination layer modify code directly, which collapses the boundary;
- Missing contracts: passing only natural language descriptions, so acceptance cannot be decided;
- Infinite retries: no budget cap, so cost spirals out of control;
- Fully synchronous chains: switch to queue-based async to avoid long tasks blocking interaction;
- Looking only at the final answer: ignoring process traceability, so problems cannot be located.
9. Implementation Checklist
- Define the three layers and their single responsibilities clearly;
- Define a subtask contract template (goal, context, constraints, acceptance, budget);
- Implement lightweight routing that reserves heavy reasoning for the execution layer;
- Make the execution layer sandboxed, network-free, and least-privilege by default;
- Establish three acceptance gates and a fallback strategy;
- Wire in logging, metrics, and alerting to form a cost dashboard;
- Review first-pass rate and human intervention rate weekly, and iterate on the contract template.
10. Closing Thoughts
The value of a multi-agent architecture does not come from “more models,” but from clearer responsibilities. Let those good at expression run the front end, send those good at logic into the sandbox, and let humans make only the trade-offs. Combined with structured contracts and a verifiable acceptance loop, this is how you balance latency, cost, and stability. The method does not depend on any specific vendor’s models, and it can be implemented in a cloud environment that provides general capabilities such as container platforms, message queues, object storage, and monitoring/alerting, including Baidu AI Cloud — as long as you write the role boundaries and acceptance criteria clearly.
