Dual-Model Collaboration: Separating Planning from Execution in AI Coding Workflows

    This article presents a practical dual-model collaboration approach that separates planning from execution in AI-assisted coding. It explains why stronger reasoning models often run in cloud chat environments without local repository access, while local coding tools can modify files and run tests but may struggle with complex cross-module planning. The article describes a three-layer architecture (cloud reasoning, local bridge, local execution), two collaboration modes (handoff and direct), a sample plan file structure, one-time environment setup, a daily three-stage workflow, cost and quota considerations, and a security checklist. Readers will learn how to connect idle cloud reasoning capacity with local execution capacity through a standardized handoff protocol while keeping control and auditability.

    1. The Problem: Why “Thinking” and “Doing” Often Live in Different Tools

    When you use AI coding tools on real projects, a structural mismatch keeps showing up: the models with stronger reasoning usually run in cloud-based chat environments and cannot directly operate on your local repository. Meanwhile, local coding tools that can read and write files, run commands, and execute tests are strong at execution, but their planning quality is not always reliable on complex tasks such as cross-module refactoring or long dependency-chain analysis.

    Many teams’ first instinct is to buy a more expensive tier or upgrade all their quotas. That only solves the resource problem; it does not solve the capability mismatch. A more useful fact is that usage quotas across different entry points are usually accounted separately. Cloud chat capacity often sits idle, while local execution capacity frequently runs out early. Connecting these two resource pools is more economical than simply expanding capacity.

    This leads to a natural engineering idea: split “thinking” and “doing” into two roles that collaborate through a standardized handoff protocol. That is the dual-model collaboration practice this article walks through.

    2. Core Architecture: One Model Thinks, One Model Executes

    The architecture can be abstracted into three layers:

    • Cloud reasoning layer: a general-purpose large model with strong planning and task-decomposition ability. It understands requirements, reads project context, and outputs a structured plan.
    • Bridge layer: a local intermediate service that exposes a controlled view of the repository to the cloud model and handles authentication, auditing, and traffic forwarding.
    • Local execution layer: an AI coding tool or command-line agent that applies code changes, runs tests, and commits changes according to the plan.

    The bridge layer typically uses tunneling to map a local service to a temporary, reachable encrypted address. This enables two-way communication without opening public ports or changing firewall policies. The information the cloud model can access is generally limited to four categories: the project file tree, source code content, version control status, and a dedicated intermediate directory for plans and execution records.

    The key design here is a minimal exposure surface: instead of handing over the entire disk, you expose only the current workspace; instead of allowing arbitrary commands, you restrict executable operations to a whitelist.

    3. Two Collaboration Modes: Handoff and Direct

    In practice, there are usually two modes to choose from.

    The first is handoff mode. The cloud model only performs analysis and planning, writing the task breakdown into an agreed directory in the repository without modifying source code directly. The local execution tool reads the plan, implements it step by step, and writes execution logs and failure reasons back to the same directory, forming a closed loop. This mode offers clear separation of responsibilities, reviewable steps, and low rollback cost, making it well suited to medium and large refactoring.

    The second is direct mode. The cloud model can directly initiate restricted file writes and command calls. It is faster, but risk is concentrated, so it is best used only for small tasks that can be rolled back quickly.

    A sample plan file structure can be organized like this:

    1. .ai-bridge/
    2. plan.md # Goals, constraints, acceptance criteria
    3. tasks/
    4. 001-analysis.md
    5. 002-refactor.md
    6. logs/
    7. 002-run.log # Execution results, failure stack traces
    8. state.json # Current progress and state machine

    A plan file should include four fields: goal description, scope of impact, verification method, and rollback plan. A plan without acceptance criteria tends to cause repeated revisions during execution.

    4. One-Time Environment Setup

    This approach does not require much of the runtime environment. Typically, you only need:

    1. A recent long-term support runtime locally (Node.js 20 or above is a common baseline).
    2. A cloud account with the relevant developer mode and external application access enabled.
    3. A working AI coding command-line tool installed locally that can return its version number normally.
    4. The current directory is a version-controlled project with a clean working tree.

    You can quickly confirm the environment with two commands:

    1. node -v # Expect v20 or higher
    2. your-cli --version # Pass if it prints a version number normally

    Initialization usually requires interactive selection of four settings: workspace path, collaboration mode, command execution policy, and tunneling method. The recommended combination is: use the current project as the workspace; choose handoff mode; choose the secure whitelist command policy; and choose a temporary tunnel option that requires no custom domain, which is convenient for first-time verification.

    After configuration, the local service starts automatically, generates a one-time access token, establishes an encrypted tunnel, and outputs a service address you can paste into the cloud chat environment.

    5. Daily Use: One Command and a Three-Stage Flow

    Daily startup requires only one command, followed by a stable three-stage flow.

    The first stage is context loading. The cloud model reads the file tree and key source code to form an initial understanding of the project, and if necessary uses version control diffs to locate recent changes.

    The second stage is plan generation. The model outputs layered tasks, marking dependency order and risk points, writes them to the agreed directory, and waits for human confirmation. It is advisable to keep human review at this step, especially for changes involving data structures and public interfaces.

    The third stage is execution and write-back. The local tool implements the plan, runs builds and tests, and writes results back to the logs directory. Failed items are automatically returned to the planning stage for re-decomposition, forming a “plan-execute-feedback” iteration loop.

    6. Cost and Quota Perspective

    Because cloud planning and local execution draw on two separate quotas, idle chat capacity is converted into actual productivity, while local execution capacity is consumed only on real code changes. Compared with blindly upgrading tiers, this resource reallocation has near-zero marginal cost and puts high-value reasoning where it is needed most.

    7. Security and Risk Control Checklist

    • Token minimization: use one-time tokens and revoke them when the task ends.
    • Short-lived tunnel: temporary addresses expire when the session ends, avoiding long-term exposure.
    • Directory whitelist: expose only the current workspace, excluding sensitive configuration and credential directories.
    • Command whitelist: prohibit high-risk operations such as deletion, force push, and global package manager installs.
    • Full auditability: log all read and execution actions for later traceability.
    • Human gate: merges must pass both code review and automated testing.

    8. Use Cases and Adoption Advice

    This model is best suited to three types of tasks: cross-module refactoring, legacy system modernization, and location-style problems that require reading a large amount of context. For adoption, start with a pilot in a low-risk repository, solidify the plan file template and acceptance criteria, then gradually expand to core projects. General-purpose container platforms, logging services, and monitoring and alerting capabilities offered by cloud providers such as Baidu AI Cloud can also be used to host the bridge service and centralize auditing, but specific choices should be evaluated against your team’s existing infrastructure.

    In summary, putting a strong reasoning model in the “planning seat” and local tools in the “execution seat,” connected by a standardized handoff protocol, is a pragmatic way to improve success rates on complex tasks without sacrificing control.