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

    This article explains why relying on a single AI model often fails in real software engineering workflows and introduces a layered scheduling architecture that separates deep reasoning, orchestration and acceptance, and execution across different model instances. You will learn how to define task contracts, isolate context to control cost and quality, build acceptance loops with static, dynamic, and semantic gates, and adapt the approach to scenarios involving GUI operations and image recognition. The article also covers advanced orchestration patterns and practical rollout advice, including metrics to track and how to productize the workflow using cloud infrastructure.

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

    After AI coding tools became part of daily development workflows, many teams started with a simple approach: pick the most capable model, feed it the entire repository and the full conversation history, and have it produce all the changes in one shot. This works surprisingly well in demos, but problems surface quickly in real engineering work.

    The first anti-pattern is the “infinite ammo” approach: keep a weaker model with limited reasoning depth running tasks and rely on repeated retries to make progress. It looks fast and cheap on the surface, but the execution tends to drift. The upstream plan may be correct, yet the downstream implementation gradually deviates: inconsistent variable naming, missing boundary conditions, and mismatched abstraction levels. Eventually you have to bring in a stronger model for review, feed it the repository and history again, and the savings you made earlier are paid back all at once.

    The second anti-pattern is “putting the cart before the horse”: the most expensive, strongest reasoning model repeatedly reads extremely long task descriptions and context history, while a weaker model writes large amounts of low-quality code. This is like having a role that “thinks little but executes well” do the thinking, and a role that “thinks a lot but executes poorly” do the implementation. Resources and output are badly mismatched.

    2. Core Idea: Abstract Model Capability into Three Dimensions

    To escape this situation, stop trying to pick a single strongest model and instead layer models by capability dimension:

    • Deep reasoning and long-range planning: determines whether vague requirements can be broken into correct steps.
    • Scheduling and acceptance: determines whether output quality can be judged and what the next step should be.
    • Execution and tool calling: determines whether code can be implemented with high quality in an isolated context, along with capabilities such as UI operation and image recognition.

    A common industry practice is to assign these three layers to model instances with different strengths, forming a “plan-schedule-execute” pipeline.

    A division of labor that has been validated in practice looks like this:

    1. Planning layer: the strongest reasoning model produces a plan in high-intensity mode, outputting only a structured task list and no code.
    2. Scheduling and acceptance layer: a model balanced between reasoning and execution runs at maximum intensity, responsible for breaking down tasks, dispatching them, comparing results, and deciding whether to rework or proceed.
    3. Execution layer: a model with lower reasoning consumption runs at low intensity, carries no history, and receives only the complete context for a single task.

    The scheduling layer acts like “middle management.” It may occasionally seem clumsy, but because the acceptance step is explicitly preserved, the results from subordinate execution can still be pulled back on track. Compared with the infinite ammo approach, this structure costs slightly more overall; but compared with having a strong model repeatedly read the full history, total consumption is significantly lower, because the execution layer does not need to repeatedly understand the entire project.

    A sample task contract can be written as:

    1. task_id: T-17
    2. goal: Add pagination parameter validation to the order query API
    3. context:
    4. files: ["src/api/order.py", "tests/test_order.py"]
    5. constraints: ["Do not modify the public response structure", "Maintain backward compatibility"]
    6. acceptance:
    7. - Add unit tests covering page<1 and size>100
    8. - All tests pass
    9. output_format: unified_diff

    The key point is that the context the execution layer receives is “just enough,” not the entire repository.

    4. Context Isolation: The Key Lever for Cost and Quality

    Longer context is not always better. Excessively long history causes three problems: attention dilution leads to key constraints being ignored, irrelevant information induces incorrect changes, and cost rises linearly or even faster with length.

    Practical recommendations include: generate a minimal necessary context package for each task; solidify long-term constraints into specification files rather than repeatedly pasting them; summarize and compress history; and make the execution layer stateless, releasing context as soon as a task ends. This avoids “repeatedly reading the entire project” and keeps each execution more focused.

    5. Acceptance Loops: Three Gates That Keep Quality Controllable

    • Static gate: type checking, static analysis, and formatting standards.
    • Dynamic gate: unit tests, integration tests, and regression tests.
    • Semantic gate: the scheduling layer checks results against acceptance criteria item by item; if anything fails, the task is redispatched with failure information.

    It is important to emphasize that acceptance criteria must be written clearly during the planning phase. Otherwise the scheduling layer can only judge by feel, and the rework rate will rise significantly.

    6. Scenario Fit: When GUI Operation and Image Recognition Are Needed

    When tasks involve GUI operation, screenshot comparison, or restoring visual designs, it is a major advantage if the execution layer has multimodal and UI operation capabilities: it can directly “see” the result and self-correct instead of guessing from text descriptions. In these scenarios, the value of the layered architecture is further amplified.

    7. Advanced Patterns and Implementation Advice

    If a team has stronger orchestration capabilities, the scheduling layer can direct the execution layer to run at low intensity while operating in high-intensity mode, forming a tighter loop. For implementation, it is recommended to: first pilot on a small repository and track three metrics—rework rate, consumption per task, and review time; then gradually expand task types; and finally templatize task contracts and acceptance checklists, turning them into team assets.

    This approach can be described as “bionics of modern management”: layering, contracting, and acceptance-driven. It does not pursue the strongest single point, but rather the stability and cost controllability of the overall system. To further reduce the cost of building your own orchestration, you can also use relevant cloud product capabilities from Baidu AI Cloud: use a container platform to host execution sandboxes, object storage to save task artifacts, and logging and monitoring services to observe pipeline quality, so that this layered approach can be implemented in engineering practice.