How to Use Multi-Agent Coding Tools Together: A Practical Architecture for Reasoning and Execution Agents
This article explains how to combine a reasoning agent and an execution agent into a single development workflow. It covers how to define role boundaries, structure the five-stage collaboration loop, package context for long-context reasoning, enforce least privilege and sandbox isolation, handle false positives from endpoint protection, and track observability and cost metrics. A deployment checklist is included.
1. Why a Single Agent Cannot Cover the Whole Development Chain
In real development work, two needs constantly pull against each other. On one side, developers need an agent that can understand a very large codebase, design documents, and historical defect records globally, and then produce complex reasoning conclusions. On the other side, they need an agent that can carry out side-effecting operations in a real environment: builds, tests, formatting, dependency installation.
Pushing both responsibilities into one runtime usually creates three problems: reasoning quality degrades under the noise of tool calls, execution permissions grow too broad and the security boundary becomes blurry, and the context window fills up quickly with logs and command output.
The industry has gradually converged on a shared view: separate “thinking” from “doing” and let two agents with different responsibilities work together. In this article, the term reasoning agent refers to the side that is good at long-text understanding and complex reasoning, and the term execution agent refers to the side that runs in a sandbox and applies commands and file changes. This layering is independent of any specific product; it is a general engineering architecture choice.
2. Defining Roles and Capability Boundaries
The first step is not picking tools, it is writing the boundaries down clearly. A responsibility matrix is a good way to fix them:
| Dimension | Reasoning Agent | Execution Agent |
|---|---|---|
| Primary input | Requirement docs, codebase index, defect history | Explicit operation instructions, patch drafts |
| Primary output | Plans, patch drafts, risk assessments | Command results, test reports, change sets |
| Permissions | Mostly read-only | Restricted write access plus sandbox |
| Failure handling | Re-reason, narrow the scope | Roll back, retry, escalate |
Once the boundaries are clear, the two agents exchange only structured artifacts rather than casual natural-language conversation. This is the key to reproducibility.
3. The Five Stages of the Collaboration Workflow
3.1 Task Decomposition and Routing
Split the requirement into “the part that needs global understanding” and “the part that needs to be applied and verified.” The routing rule is simple: anything involving cross-module impact analysis, interface contract design, or performance bottleneck attribution goes to the reasoning side; anything involving compilation, unit tests, static checks, or dependency changes goes to the execution side.
3.2 Context Packaging and Handoff
Do not hand the entire repository to the reasoning side. Generate a compact context package instead, containing a directory structure summary, key interface signatures, a list of relevant unit tests, and constraints. An example structure:
{"task_id": "T-2024-0731","goal": "Add a configurable expiration policy to the cache layer","context": {"entry_files": ["src/cache/manager.ts"],"interfaces": ["get(key)", "set(key, val, ttl)"],"constraints": ["Do not change existing unit test assertions", "Keep backward compatibility"]},"acceptance": ["All unit tests pass", "Add 3 boundary cases"]}
3.3 Patch Generation and Static Pre-Review
The reasoning side outputs a patch draft with a change description, followed by a static pre-review: does the list of changed files stay in scope, does it touch permission-sensitive directories, does it introduce new external dependencies. If the pre-review fails, the patch is sent back and never enters the execution stage.
3.4 Sandboxed Execution and Feedback Loop
The execution side applies the patch in an isolated environment, runs the build and tests, and returns structured results: exit code, failing cases, elapsed time, and a log summary rather than the full log. On failure, only the minimum necessary information is returned so the context is not polluted.
3.5 Attribution and Iteration
If execution fails, the reasoning side re-reasons from the failure summary, for a bounded number of rounds. Once the threshold is exceeded, the task escalates to a human to prevent an infinite loop from consuming resources.
4. Security Boundary Design: Least Privilege and Sandbox Isolation
The risk in this architecture concentrates on the execution side, and four measures are required:
- Least privilege: grant write access only to the target directory; deny access to credential directories, system configuration, and outbound network access (except for necessary dependency sources).
- Sandbox isolation: run the execution environment in a container or a disposable virtual machine, destroyed when the task ends, so leftover state cannot affect the next run.
- Command allowlist: fix the permitted commands in a list, and deny dangerous operations by default (recursive deletion, bulk rewrites, permission changes).
- Full audit trail: record instructions, patch hashes, and execution results to form an auditable chain for later tracing and accountability.
5. A Common Engineering Issue: Runtime Behavior Misjudged by Security Software
Because the execution agent must read and write files in protected directories and inject runtime processes, endpoint protection mechanisms often flag it as suspicious behavior. The symptoms are interrupted builds, quarantined files, and terminated processes. The right approach is to place a “trusted but unusual” program under a controlled allowlist, not to disable protection.
The general procedure:
- Locate the executable and its installation directory, and record its hash as a baseline for later verification.
- Open the trust zone or exclusion settings of the endpoint protection software; the entry point is named differently across products.
- Prefer adding a directory rather than a single file, so updates, cache files, and logs are covered; keep the exclusion scope as narrow as possible, limited to the dedicated directory.
- Restart the relevant processes and retest to confirm the alerts are gone and the rest of the protection still works.
If the endpoint is managed centrally by an organization and you have no authority to change the policy, submit the project description, file hashes, and an explanation of the behavior to the managing team and go through the internal approval process. Never disable protection components on your own. Note that allowlisting reduces false positives; it does not replace sandboxing and least privilege. The two are additive.
6. Observability and Cost Control
Multi-agent collaboration amplifies call volume, so three categories of metrics are needed: task success rate, average number of iterations, and resource consumption per task. Trimming the context package and reusing cached context, plus building a rule library that short-circuits repeated failure patterns, can cut cost significantly. On the logging side, connect to a unified logging service with monitoring and alerting, and set threshold alerts for abnormal iteration, permission denials, and sandbox escape attempts.
7. Deployment Checklist
- Is the responsibility matrix written down and included in review?
- Is the context package structured and does it include acceptance criteria?
- Does the execution side run in a disposable sandbox with least privilege?
- Is there a command allowlist with interception of dangerous operations?
- Are false-positive exclusions limited to a dedicated directory with hash verification retained?
- Are audit trails, a metrics dashboard, and a human fallback path in place?
With this architecture in place, reasoning and execution each do their own job: reasoning quality on complex tasks is preserved, side effects stay within a controllable range, and the result is a reusable, auditable, and extensible agent collaboration pipeline.
