A Practical Guide to Multi-Agent Coexistence Architecture on a Single Machine
This article explores why AI agents tend to fall into two extremes: strong at planning but weak at execution, or unable to stop once execution begins. It presents a layered multi-agent coexistence architecture for a single machine, covering an access layer, a session and routing layer, a unified model access layer, and an execution layer with sandbox and permission controls. It then explains how to turn intent into verifiable actions, how to enforce budgets, circuit breakers, and termination checks, and how to handle observability and cost control, followed by a step-by-step implementation path.
1. Background: Reexamining Two Extreme Behavior Patterns
When teams deploy agent systems in practice, they often run into two very different patterns. In the first, the agent is strong at planning but weak at execution: it produces well-structured, complete proposals, but when real implementation is required, it repeatedly claims to be in a restricted environment or to lack the necessary permissions. The task never moves forward, and humans have to keep pushing it. The second pattern is the opposite: once execution starts, the agent struggles to converge. It keeps calling tools and expanding the scope until it hits a timeout or a resource limit and is forcibly interrupted.
Neither pattern is simply a matter of capability level. Both are the result of configuration differences across three dimensions—permission boundaries, termination conditions, and feedback mechanisms—amplified in practice. Understanding this is the prerequisite for building a single-machine coexistence architecture.
1.1 Root Causes of the Behavioral Differences
- Permission and sandbox constraints: In a restricted sandbox, file system access, network egress, and process invocation may all be trimmed, leaving the agent “willing in intent but unable in practice.”
- Missing termination conditions: Without a clear completion criterion and budget cap, the agent treats “keep trying” as the optimal choice and falls into an infinite loop.
- Weak feedback loop: Execution results are not returned in a structured form, so the model cannot tell whether the task is complete and has to guess based on conversational context.
1.2 Why Choose “Coexistence” Instead of “Either-Or”
In engineering practice, the best solution is usually not to pick one type of agent, but to assign different responsibilities to agents with different behavioral traits: one that excels at plan decomposition and interactive communication, suited as the front-end conversational entry point; another that excels at long-chain execution, suited as a back-end task executor. The core value of coexistence is separation of responsibilities and risk isolation.
2. Target Architecture: A Layered Design for Multi-Agent Coexistence on a Single Machine
A four-layer structure is recommended, with clearly defined interfaces between layers so that agents do not couple directly to low-level resources.
Access layer (multiple terminal channels)↓Session and routing layer (intent recognition / dispatch)↓Unified model access layer (model abstraction + quota governance)↓Execution layer (sandbox runtime + toolset + resource quotas)
2.1 Access Layer: Routing Interactions by Scenario
Different terminals suit different interaction rhythms. Mobile is suited to fragmented, short-turn Q&A and confirmations; a desktop browser is suited to long-text review, log inspection, and multi-turn iteration. Mapping the two entry points to different agents can significantly improve the experience without changing the underlying capabilities.
- Mobile channel: focused on “confirmation, approval, and status queries” to reduce the risk of misoperation.
- Desktop channel: focused on “proposal generation, code review, and batch execution” to handle high-complexity tasks.
2.2 Session and Routing Layer: Sending Requests to the Right Executor
The routing layer needs to maintain a capability mapping table that maps intent labels to specific agents. A sketch implementation:
ROUTER = {"plan": "agent_planner", # strong planning, weak execution"execute":"agent_executor", # long-chain execution"review": "agent_planner",}def route(intent: str, payload: dict):target = ROUTER.get(intent, "agent_planner")return dispatch(target, payload)
The key point is that routing decisions should be based on intent and risk level, not user preference; high-risk operations must go through an approval channel.
2.3 Unified Model Access Layer: Sharing One Model Service
Having multiple agents call the same model service is the most effective way to reduce cost and unify the behavioral baseline. This layer should take on three responsibilities:
- Interface abstraction: hide differences between underlying models and expose a unified inference interface.
- Quota governance: allocate token budgets by agent and by session to prevent a single agent from exhausting resources.
- Call auditing: record an input summary, output summary, and latency for each request to support troubleshooting.
2.4 Execution Layer: Fine-Grained Sandbox and Permission Configuration
A sandbox is not “better the stricter it is.” Over-tightening leaves the agent unable to act; fully opening it up brings security and cost risks. The recommended approach is to grade permissions by task type:
| Task level | File system | Network egress | Execution duration |
|---|---|---|---|
| Read-only analysis | Read-only mount | Restricted allowlist | Short |
| Internal change | Working directory writable | None | Medium |
| External interaction | Working directory writable | Allowlist | Medium, approval required |
3. Fixing “All Talk, No Action”: Turning Intent into Verifiable Actions
For insufficient willingness to execute, repeated prompting is not the answer; mechanism-based constraints are.
- Enforce structured output: require the agent to first produce a task list, where each item includes preconditions, the execution command, the expected artifact, and the verification method.
- Precondition pre-check: check dependencies uniformly before execution and return all missing items at once, rather than declaring restrictions halfway through.
- Minimal actionable units: break large tasks into the smallest units that can be completed within a single session, ensuring visible output every round.
{"task": "generate monthly report","steps": [{"action": "read", "target": "/data/sales.csv", "verify": "file_exists"},{"action": "transform", "target": "aggregate_by_region", "verify": "row_count>0"},{"action": "write", "target": "/out/report.md", "verify": "non_empty"}]}
4. Fixing “Unable to Stop”: Budgets, Circuit Breakers, and Termination Criteria
For the infinite-execution problem, three guardrails are needed:
- Budget guardrail: cap the maximum number of turns, maximum tool calls, and maximum duration per task.
- Circuit breaker: when consecutive failures reach a threshold, abort and roll back to a checkpoint to avoid invalid retries amplifying cost.
- Termination criterion: use “whether the artifact passes verification” as the completion standard, rather than the model’s own claim.
def run_with_guard(task, budget):for step in task.steps:if budget.remaining() <= 0:return {"status": "aborted", "reason": "budget_exhausted"}result = execute(step)if not verify(step, result):budget.penalize()if budget.failures() >= 3:return {"status": "rolled_back", "checkpoint": budget.last_ok()}return {"status": "done", "artifacts": task.artifacts()}
5. Observability and Cost Control
Under a coexistence architecture, multiple agents share resources, making observability a requirement rather than an option.
- Metrics: track call volume, success rate, average latency, timeout rate, and token consumption per agent.
- Logs: use a unified log format that ties together session identifiers and task identifiers for cross-agent tracing.
- Alerts: set threshold alerts on timeout and failure rates; once triggered, automatically degrade to read-only mode.
- Cost: combine with a message queue for asynchronous queuing, placing long-chain tasks in the background so they do not occupy the interactive channel; large artifacts can be written to object storage, with only a reference address passed in the session.
6. Recommended Implementation Steps
- First unify the model access layer and establish a baseline for quotas and auditing.
- Then configure sandbox permissions by task level to complete the security boundary.
- Next implement the routing layer and the structured task protocol to connect the “intent to action” path.
- Finally add budgets, circuit breakers, and observability to form closed-loop governance.
Following this path, multiple agents with complementary behavioral traits can run stably in a single-machine environment: you retain the interaction friendliness of the strong planner and the output capability of the strong executor, while controlling risk and cost through a unified governance layer.
