Hierarchical Scheduling for Multi-Model Collaborative Coding

    This article explains why relying on a single model for the entire coding workflow breaks down in real repositories, and how a three-tier structure separates reasoning from execution. You will see the roles of the planning, scheduling and review, and execution layers, the principle that execution tasks must be self-contained with no inherited history, three common failure modes and how to avoid them, a revised view of token cost, and practical steps for adopting this layered orchestration approach.

    1. Background: Why One Model Cannot Do Everything

    Once AI coding tools became part of daily development workflows, a recurring pattern emerged: a model that performs well during planning often degrades sharply once it enters a long execution chain, while fast, low-cost models tend to lose sight of global constraints. Many teams initially used a setup of “high compute tier in the browser for planning, a lower tier for batch dispatch and acceptance, and the highest throughput tier for endless execution loops” — the so-called “infinite ammo” mode.

    This mode works well in demos, but in a real repository it quickly exposes three problems.

    First, execution drift. The plan is correct, but execution damages the architecture, forcing you to bring in a stronger model for review and stuff the entire repository and full conversation history back into context — and token consumption spikes again.

    Second, role mismatch. The most expensive reasoning model is repeatedly made to read extremely long task descriptions and history, while the model best at “think less, do more” writes large amounts of low-quality code. In essence, the best thinker does the work that needs the least thinking, and the weakest thinker does the work that needs the most judgment.

    Third, out-of-control context cost. Long histories are read over and over, cache hit rates drop, and the actual cost per task is far higher than the theoretical estimate.

    2. Core Idea: Split “Thinking” and “Doing” into Two Things

    A more reasonable approach is to reassign roles into a three-tier structure:

    • Planning layer: high reasoning tier, high thinking budget, responsible only for goal clarification, solution design, and constraint definition;
    • Scheduling and acceptance layer: middle tier, maximum output budget, responsible for task decomposition, dispatch, result verification, and rollback decisions, acting as “middle management”;
    • Execution layer: low thinking tier, low latency, no historical context, receiving only a single self-contained task and delivering a result.

    The key design principle is: the execution layer does not inherit history. Every dispatched task must be self-contained, including the goal, the scope of files involved, constraints, acceptance criteria, and rollback method. This both prevents the execution layer from being distracted by irrelevant context and stops it from repeatedly reading the entire project.

    A schematic dispatch structure is shown below (pseudocode, expressing only the layered idea):

    1. plan = strong_reasoner.plan(goal, repo_outline) # outputs only a structured task list
    2. for task in plan.tasks: # each task is self-contained
    3. result = cheap_executor.run(task.to_prompt()) # no history, single task
    4. verdict = middle_manager.review(task, result) # scheduling layer acceptance
    5. if not verdict.passed:
    6. result = cheap_executor.run(task.with_fix(verdict.notes))

    3. Three Typical Failure Modes and How to Avoid Them

    Context bloat failure: shows up as a single request carrying hundreds of thousands of characters of history, diluting the model’s attention. The countermeasure is to enforce a context budget: planning-layer output must be structured, and execution-layer input must be trimmed to a single task boundary.

    Instruction decay failure: the longer the task description, the more easily key constraints are ignored. The countermeasure is to write constraints as verifiable items, such as “do not modify public interface signatures” and “must preserve existing error handling branches,” and check them one by one during acceptance.

    Missing acceptance failure: without independent acceptance, errors accumulate along the chain. The countermeasure is to have the scheduling layer and the execution layer use different models, avoiding the blind spot of “judging yourself”; acceptance conclusions must be machine-readable structured results, not natural-language impressions.

    4. Reassessing the Cost Structure

    The total token consumption of the layered approach is usually higher than “infinite ammo” but lower than “using the strongest model at a low tier throughout,” for three reasons: the execution layer no longer re-reads the full history; planning results are reusable, reducing rework; and errors are intercepted at single-task granularity, avoiding large-scale rollbacks.

    With more complete orchestration capabilities, such as programmable session orchestration and tool-calling channels, a strong reasoning model can act as commander while lower-tier models handle execution, making the chain run more smoothly — but this is an engineering capability issue, not a model selection issue.

    5. Implementation Recommendations

    1. First establish task templates that fix the four sections: goal / scope / constraints / acceptance;
    2. Set a hard context limit for the execution layer, and split the task once it is exceeded;
    3. Have the acceptance layer output structured conclusions; on failure, automatically redispatch once, and escalate to the planning layer on a second failure;
    4. For scenarios involving UI operations, image recognition, and the like, prefer an execution tier with multimodal capabilities;
    5. Use logging services and monitoring alerts to track rework rate and per-task cost, and keep tuning parameters.

    This structure can be called “bionics of modern management”: the middle layer looks somewhat clumsy, but the subordinates actually get the work done right. In related engineering practice at Baidu AI Cloud, this kind of layered orchestration approach likewise applies to building stable, controllable, and cost-budgetable automated development pipelines.