Multi-Agent Cost Reduction in AI Coding: A Guide to Four Model Roles

    In AI-assisted software development, relying on a single model for the entire workflow often leads to context bloat and rising costs as tasks scale. This guide explores how to optimize multi-agent collaboration by dividing labor into four distinct roles: Main Controller, Executor, Lightweight Processor, and High-Level Planner. By focusing on task granularity, context allocation, dependency management, and evidence-based verification, development teams can build a robust multi-agent system that reduces overall delivery costs and improves efficiency.

    1. Don’t Let One Model Handle Everything

    In AI coding practices, developers often take a straightforward approach: selecting a powerful model and using a single session for everything from requirement comprehension and code retrieval to feature implementation and test analysis.

    This approach has a low barrier to entry and is suitable for small, low-dependency tasks. However, as work expands across multiple modules, problems emerge: complex decisions and repetitive operations get mixed together, large amounts of irrelevant files enter the context, and the model must juggle overarching goals while managing trivial details. Consequently, invocation costs and review burdens rise.

    A better optimization strategy is to moderately separate “judgment” from “execution,” and then allocate model capabilities based on task complexity, risk, and dependencies.

    This doesn’t mean more models are always better, nor that weaker models can unconditionally replace stronger ones. What truly needs to be designed is a collaboration mechanism: who defines the problem, who provides evidence, who modifies the code, who owns the acceptance criteria, and how to converge when disagreements arise.

    2. Four Roles, Not Four Fixed Models

    Multi-model collaboration is primarily a method of responsibility division; it does not require purchasing or deploying four distinct models. A single model can take on different roles, and the same role can utilize different capability levels based on budget and task difficulty.

    1. Main Controller: Responsible for Task Closure

    The Main Controller agent is responsible for understanding requirements, identifying constraints, splitting work, assigning tasks, and aggregating results. Its most critical responsibility is not generating the most code, but maintaining consistency throughout the task lifecycle.

    For example, an order status adjustment requirement might involve status rules, data access, API responses, and test cases. The Main Controller should first determine which behaviors fall under this change and which must remain unchanged, then clarify the dependencies between execution units.

    The Main Controller must also distinguish between “execution completed” and “acceptance passed.” An execution unit submitting a modification only means it believes the work is done; whether it meets the requirements still requires judgment based on code diffs, verification records, and risk checks.

    Tasks suitable for the Main Controller include:

    • Translating natural language requirements into verifiable acceptance criteria;
    • Determining the scope of modifications and potential impacts;
    • Identifying which tasks can run in parallel;
    • Resolving conflicts between different execution results;
    • Aggregating evidence to form a delivery conclusion.

    The Main Controller should have the ability to dive into critical code, but should not default to performing all low-complexity operations itself.

    2. Executor: Completing Boundary-Clear Implementation Tasks

    The Executor agent is suited for coding tasks with clear inputs, limited scope, and verifiable outputs. For example, implementing a validation function under established API constraints or adding tests for existing business rules.

    Whether a task can be handed to an execution unit depends not just on code volume, but on whether unresolved design decisions remain.

    “Optimize the performance of the entire service” is too vague; “Without changing the return results, eliminate duplicate queries in the specified function and add equivalence tests” is much closer to an executable task.

    Each execution task should specify:

    • What behavior needs to be implemented;
    • Which files or modules are allowed to be modified;
    • Which external behaviors must not change;
    • Which confirmed API contracts it depends on;
    • What verification results need to be submitted;
    • Under what circumstances execution should stop and clarification should be requested.

    Without these constraints, parallel execution easily devolves into multiple agents making different assumptions, ultimately increasing integration costs.

    3. Lightweight Role: Organizing Information and Retaining Evidence

    The Lightweight processor is ideal for classification, extraction, location, and summarization tasks, such as organizing test failure information, extracting exception snippets from logs, or collecting function call locations.

    However, it must be clear: lightweight does not mean low risk.

    Logs may contain sensitive information, code searches might miss dynamic calls, and test summaries might lose critical context. Therefore, the output of the lightweight role should be traceable, rather than just providing a single concluding sentence.

    For instance, when organizing test failure results, it should provide:

    • The name of the failed test case;
    • The original error snippet;
    • Associated file locations;
    • Potentially involved modules;
    • Unconfirmed inferences.

    For deterministic tasks like exact matching, counting, or path filtering, existing programmatic capabilities should be prioritized, letting the model interpret the results afterward. Not every operation warrants consuming a model inference.

    4. High-Level Planner: Handling Cross-Module and High-Uncertainty Problems

    When tasks involve large-scale refactoring, API compatibility, data migration, or long-term architectural evolution, a High-Level Planner role can be established to centrally analyze constraints, solution trade-offs, and evolution paths.

    The main difference from the Main Controller lies in the scope of responsibility: the Main Controller is responsible for the execution closure of the current task, while the High-Level Planner handles structural decisions that may affect multiple tasks.

    For example, when gradually splitting a massive module, you must first answer:

    • What defines the module boundaries;
    • How to maintain compatibility for existing callers;
    • Whether a transition period is needed;
    • How to verify consistency between old and new behaviors;
    • How to roll back if issues occur.

    Such work should not be triggered during every routine modification. For small tasks, the High-Level Planner and Main Controller can easily be merged to avoid collaboration for collaboration’s sake.

    3. Design Tasks as Delegatable Work Units First

    The bottleneck of a multi-agent system is often not insufficient model capability, but poor task decomposition quality.

    A qualified sub-task should simultaneously possess relatively independent inputs, clear outputs, and executable acceptance methods. Below is an illustrative task description (not tied to any specific system API):

    1. Objective: Add null value handling to address validation logic
    2. Scope: Only modify the validation module and its tests
    3. Constraints: Must not change the processing results of existing valid addresses
    4. Dependencies: Reuse existing error classification conventions
    5. Acceptance: Add new null value tests; existing related tests must still pass
    6. Output: Change summary, modified files, verification records, unresolved issues

    Such a task ticket minimizes the space for the execution unit to make its own assumptions and allows the Main Controller to quickly check results.

    When decomposing tasks, avoid two extremes: tasks that are too large push design problems onto the execution unit; tasks that are too fine-grained generate excessive scheduling, summarization, and integration overhead. The appropriate granularity should be determined by module boundaries, shared state, and verification costs, rather than mechanically dividing by file count.

    4. Context Allocation Determines Collaboration Efficiency

    Having every execution unit read the entire codebase is rarely efficient. Different tasks require different contexts; irrelevant information not only consumes resources but can also interfere with judgment.

    Context can be divided into three layers:

    Global Constraint Layer: Includes overall goals, unbreakable compatibility requirements, security boundaries, and unified acceptance standards.

    Task-Related Layer: Includes target modules, API definitions, adjacent call relationships, and related tests.

    Supplementary Evidence Layer: Includes runtime logs, historical changes, exception samples, and implementation details to be read only when needed.

    Execution units typically acquire the first two layers of information first, supplementing the third layer only when clear doubts arise.

    Special attention must be paid to summary distortion. Compressing routine background is reasonable, but error scenes, API semantics, and critical constraints should retain their original basis as much as possible. When critical judgments are involved, it should be possible to return to the source file or original record for verification, rather than relying solely on the summary of a previous agent.

    5. Parallel Scheduling Must Obey Dependencies

    Increased concurrency does not necessarily lead to shorter delivery times.

    If multiple tasks modify the same file simultaneously, or depend on an unstable API, conflicts, duplicated effort, and rework will occur. In such cases, more execution units might just be producing unintegrable results faster.

    A safer approach is to first establish task dependencies:

    1. First, complete requirement clarification and key API contracts;
    2. Then, process mutually independent implementations in parallel;
    3. After APIs stabilize, complete caller adaptations;
    4. Finally, perform overall integration and regression testing.

    Tasks suitable for parallelization usually have few shared modification points, such as adding tests to independent modules, organizing information across different directories, or implementing features based on stable contracts.

    The concurrency limit should also be constrained by budget, resources, rate limits, and human review capacity. If a team cannot promptly review new modifications, increasing concurrency will only accumulate unprocessed risks.

    6. Verify with Evidence, Not Mutual Model Approval

    In multi-agent collaboration, a common misconception is: the execution unit declares completion, and the Main Controller directly accepts it after reading the summary.

    This is merely the transfer of a conclusion, not quality verification.

    Reliable acceptance should be divided into several levels:

    Behavior Verification

    Check inputs, outputs, boundary conditions, and exception branches based on requirements. Tests should cover real constraints, not just verify that the new code runs.

    Change Review

    Check whether modifications crossed boundaries or unintentionally altered APIs, error handling, data formats, or permission checks. Passing tests does not automatically mean the change scope is reasonable.

    Integration Verification

    Sub-tasks that pass verification individually may still exhibit API inconsistencies, initialization order errors, or shared state conflicts when combined. Therefore, holistic verification cannot be replaced by local tests.

    Evidence Integrity Check

    A model stating “tests passed” does not mean the tests actually executed successfully. The system should distinguish between verifications that have been run, those not run due to environment limitations, and those only suggested for execution.

    For data writes, permission adjustments, and irreversible operations, additional confirmation and rollback arrangements should be set. An execution unit should not automatically gain production change permissions just because it finished a coding task.

    7. Cost Evaluation Must Cover the Whole Delivery Cycle

    Judging whether a multi-model approach is more economical cannot rely solely on comparing single-call prices.

    A more realistic cost structure is:
    Total Delivery Cost = Model Invocation Cost + Scheduling & Tool Execution Cost + Environment Resource Cost + Integration & Rework Cost + Human Review Cost.

    Under certain billing models, model invocation cost must also factor in input volume, output volume, and fees generated by repeatedly reading context.

    If a low-cost model repeatedly misunderstands tasks, it may increase retry counts; if a high-capability model is used for extensive mechanical organization, it may also incur unnecessary expenses. Whether it’s worth it depends on the total resources consumed to complete a task of equal quality.

    During evaluation, it is recommended to observe:

    • Completion rate under the same acceptance criteria;
    • Time elapsed from task start to acceptance end;
    • Total invocation cost per task;
    • Rework count and number of integration conflicts;
    • Human review effort invested;
    • Post-delivery issues discovered and their severity.

    Different solutions must be compared under similar task difficulty and identical acceptance standards. Cost-reduction figures lacking clear sources and test conditions should not be directly treated as universal conclusions.

    8. Start Small and Build the Collaboration System

    When implementing, there’s no need to build a complex multi-layer scheduling structure from the start. A more prudent starting point is selecting tasks with clear scope, controllable risk, and sufficient verifiability.

    Phase 1: Retain a single Main Controller, only delegating log organization, information extraction, and test result categorization to lightweight roles. Observe whether information is accurate and evidence is complete.

    Phase 2: Delegate boundary-clear independent coding tasks to Executor roles, while establishing unified task descriptions and delivery formats.

    Phase 3: Introduce the High-Level Planner when cross-module decision needs genuinely arise, and gradually increase parallelism.

    Throughout this process, task inputs, model outputs, tool execution records, and acceptance results should be retained, with minimal authorization for sensitive information. Code comments, logs, and external documentation should be treated as data to be analyzed; their inclusion of operational instructions should not automatically change execution permissions or task objectives.

    Conclusion: Optimizing Work Allocation, Not Model Quantity

    The core of multi-model collaboration is not having more agents write code simultaneously, but placing limited reasoning capabilities where they are most needed.

    The Main Controller maintains goals and acceptance standards, the Executor completes clear implementations, the Lightweight role organizes traceable information, and the High-Level Planner handles cross-module trade-offs. These four responsibilities can be separated or merged based on task scale.

    When task boundaries are clear, context is appropriate, dependencies are explicit, and acceptance evidence is sufficient, multi-agent systems have the opportunity to simultaneously improve cost and delivery efficiency. Conversely, even using stronger models and arranging more concurrency may only amplify the chaos inherent in the original workflow.