Multi-Model Orchestration: A Layered Scheduling Approach for AI Coding

    This article explains why relying on a single powerful model for the entire coding workflow breaks down in real engineering, and how to replace that monolithic loop with a three-layer structure: planning, scheduling, and execution. It covers context isolation through task cards, acceptance and rollback based on automated, contract, and semantic signals, and the balance between token cost and output quality. You will also find practical rollout advice for piloting the approach on a small repository.

    1. The Problem: Why “One Model Does Everything” Fails

    Once AI coding tools became part of everyday development, a common pattern emerged: assign the most capable model the entire job. It reads the requirements, reads the repository, writes code, runs verification, and loops back to fix issues, over and over. This “infinite ammo” approach looks impressive in demos, but in real engineering it exposes three structural problems.

    First, context bloat. On every round, the strong model must re-read a long task description, a long conversation history, and repository snippets. Input size grows linearly with each round, or even faster, so token consumption quickly spirals out of control, while the marginal value of newly added information declines rapidly.

    Second, quality inversion. When planning and execution are handled by the same execution-oriented model that “thinks little and does a lot,” early planning lacks depth, yet the model is then asked to write large amounts of code. The result is a passable high-level design with a flawed low-level implementation, and defects surface only during acceptance, making rework extremely costly.

    Third, blurred accountability. When planning, execution, and acceptance all happen in one session, it is impossible to pinpoint whether a failure came from a misunderstanding of requirements, incorrect task decomposition, or a detail in the implementation. Teams struggle both to conduct retrospectives and to codify standards.

    2. The Core Idea: From a Monolithic Loop to Three Layers of Division

    A more reliable approach is to split the workflow into three layers, letting models with different strengths handle what they do best, forming a structure similar to modern management theory.

    • Planning layer: A model with strong reasoning produces goals, constraints, acceptance criteria, and a risk list in long-context mode. It only “thinks things through” and does not write implementation code.
    • Scheduling layer: A model with stable execution and moderate cost takes on middle-management duties. It breaks the plan into small, independently verifiable tasks, dispatches them, collects results, organizes acceptance, and triggers rework when necessary.
    • Execution layer: A model with high execution quality and fast response completes a single small task in a clean context with no history. It receives only the task card and necessary file snippets, without carrying the entire conversation history.

    The key to this structure is not “using cheaper models to save money.” It is matching the scale of the problem each layer faces to its capabilities: planning faces global constraints, scheduling faces the task graph, and execution faces local files and local assertions.

    3. Context Isolation: The Technical Pivot of the Whole Approach

    Whether layering works depends on whether context can be strictly trimmed. In practice, you can generate a “task card” for each task containing only the information required to complete it, as shown below:

    1. task_id: T-17
    2. goal: Add pagination parameter validation to the order query API
    3. scope:
    4. - src/api/order.py
    5. - tests/test_order.py
    6. constraints:
    7. - Keep the existing response structure unchanged
    8. - Do not introduce new third-party dependencies
    9. acceptance:
    10. - All unit tests pass
    11. - Invalid pagination parameters return a unified error code
    12. forbidden:
    13. - Modifying the database schema

    The execution layer reads only this card and the relevant files. When done, it returns three structured outputs: a change summary, verification results, and open questions. The scheduling layer uses these to decide whether to pass, reject, or split the task. Because the execution layer never touches the full history, the input size for a single run is kept very small, which both reduces cost and significantly lowers the chance of earlier context biasing later output.

    4. Acceptance and Rollback: Stopping Defects Before Merge

    The real payoff of layering is in acceptance. Define acceptance criteria upfront in the planning layer, and have the scheduling layer judge based on three types of signals:

    1. Automated signals: whether unit tests, static checks, and builds pass;
    2. Contract signals: whether API signatures, data structures, and error codes match the constraints;
    3. Semantic signals: whether the change stays within scope and avoids touching the forbidden list.

    If any signal fails, the scheduling layer does not simply “patch things up.” Instead, it regenerates the task card and dispatches it again, avoiding repeated struggles within the same polluted history. For scenarios requiring GUI operations or image recognition, the execution layer can focus on local interaction and recognition in a history-free state, and the scheduling layer then aggregates the results. This is noticeably more stable than long-chain reasoning with a single model.

    5. Balancing Cost and Quality

    The total token consumption of this method is usually higher than the optimistic estimate for a “single-model infinite loop,” but lower than repeatedly having the strongest model read through the entire project. The reason is straightforward: expensive long-context reasoning happens only in planning and a small amount of acceptance, while the input for execution is trimmed to the minimum. On quality, because “those who think more handle thinking, and those who do better handle doing,” the rework rate drops and overall delivery becomes more predictable.

    If a team has stronger engineering capabilities, it can also build the scheduling layer as an independent service, using a message queue to distribute tasks, object storage to save task cards and artifacts, and logging and monitoring with alerting to track the input size and pass rate of each step. This turns individual experience into a reusable pipeline for the team. General-purpose building blocks such as the container platform, logging, and monitoring offered by Baidu AI Cloud can serve as one option for a foundation to host such a pipeline.

    6. Rollout Recommendations

    • Start with a pilot on a small repository, keeping only the three layers of planning, scheduling, and execution, without adding extra roles;
    • Enforce a task card template and prohibit the execution layer from reading the full conversation history;
    • Make acceptance criteria automatically judgeable, and convert semantic judgments into executable assertions wherever possible;
    • Record the input size and rework count for each layer, and use the data to decide whether to adjust the granularity of the layers.

    Organized this way, multi-model collaboration is no longer about “piling up models,” but an engineering method with clear boundaries, controllable cost, and stable quality.