Tiered Agent Orchestration: Using Large and Small Models to Lower AI Coding Costs
This article explains how tiered agent collaboration assigns AI coding tasks to models matched to each task's difficulty. It covers why sending low-reasoning work to the most capable model inflates costs, how to route tasks using observable criteria, a four-step collaboration workflow, a method for estimating total cost that includes coordination overhead, and practical safeguards for deployment.
1. Where the Problem Lies
As AI-assisted programming becomes part of daily development, many teams run into the same situation: every task goes to the most capable model. Work such as searching files, reading logs, and summarizing test reports does not require strong reasoning, yet it is billed at the highest unit price. At the same time, tasks that need judgment, such as breaking down requirements, designing interfaces, and reviewing risky changes, often suffer in quality because their context is crowded with minor details.
Cost therefore has two layers. The first is unit price. The second is how tokens are distributed across tasks. The second layer is often overlooked. In a programming task, reading code, retrieving files, and summarizing output usually consume most of the tokens, while the parts that determine direction account for only a small share. If this large volume of mechanical work is also done by a high-priced model, costs are amplified.
2. Basic Structure of Tiered Collaboration
Tiered collaboration divides agents into several roles. Each role uses a model that matches its level of difficulty.
| Role | Primary responsibilities | Suited capability profile |
|---|---|---|
| Lead agent | Task decomposition, key decisions, core code, final acceptance | Strongest reasoning ability |
| Execution worker | Parallel development with clear boundaries, independent feature implementation | Stable coding, moderate unit price |
| Light worker | File search, log reading, classification, information extraction, test result summarization | Fast, low unit price |
| Coordination role (enabled as needed) | Large refactoring plans, architecture planning, complex research | Strong long-context and cross-module reasoning |
This structure relies on several design principles.
- The lead agent only makes judgments and does not perform large-scale raw reading. It should receive summaries and structured results, not complete logs or entire source files.
- Workers do not depend on each other. When splitting tasks, make sure subtasks have non-overlapping file scopes. Otherwise, parallel changes will conflict, and merging costs will rise.
- Light workers produce output in a fixed format, such as JSON, so the lead agent can parse and aggregate it directly. This reduces the overhead of reinterpretation.
- The coordination role is not always on. It is activated only during planning or when a cross-module problem arises, so it does not consume budget at other times.
3. Task Routing: Deciding Who Does the Work
Routing is the core of tiered collaboration. Routing rules do not need to be complex, but they must rely on observable dimensions rather than intuition. Four common criteria are listed below.
- Ambiguity: Whether the requirements are clear and whether several reasonable interpretations exist. Higher ambiguity calls for more involvement from the lead agent.
- Blast radius: Whether the change spans modules or affects public interfaces, data structures, or permission settings. A larger blast radius calls for oversight from a higher-tier role.
- Verifiability: Whether the result can be checked automatically through tests, type checks, or rules. Tasks that can be verified automatically can be handled by light roles, with the pipeline serving as a safety net.
- Reasoning need: Whether the task requires weighing trade-offs between multiple options. Tasks that require trade-offs should go to a role with stronger reasoning.
The following is an illustrative routing function:
from dataclasses import dataclassfrom enum import Enumclass Tier(Enum):LEAD = "lead" # Lead agent: planning, complex decisions, acceptanceWORKER = "worker" # Execution worker: coding tasks with clear boundariesLIGHT = "light" # Light worker: search, extraction, classification@dataclassclass Task:description: strambiguity: int # Ambiguity level, 0 to 3blast_radius: int # Blast radius, 0 to 3verifiable: bool # Whether the result can be verified automaticallyneeds_reasoning: bool # Whether trade-off reasoning is requireddef route(task: Task) -> Tier:# High ambiguity or large blast radius goes to the lead agentif task.ambiguity >= 2 or task.blast_radius >= 2:return Tier.LEAD# No reasoning needed and automatically verifiable goes to a light workerif task.verifiable and not task.needs_reasoning:return Tier.LIGHT# Remaining coding tasks with clear boundaries go to an execution workerreturn Tier.WORKER
After a routing rule goes live, check its effect with logs. Record the routing result, token usage, and whether each task was reworked in the end. After several weeks of operation, adjust the thresholds based on the data. This is more reliable than trying to write a perfect rule from the start.
4. Collaboration Workflow
A typical tiered collaboration workflow has four steps.
- Planning: The lead agent reads the requirements and repository structure, then outputs a list of subtasks. Each subtask must specify its target files, input information, and acceptance criteria.
- Dispatch: The routing function determines the executing role for each subtask. Tasks that do not conflict are dispatched in parallel.
- Collection: Execution results return in a unified structure. Failed tasks enter a retry queue, and tasks that fail repeatedly are escalated.
- Acceptance: The lead agent reviews the results against the acceptance criteria and runs the full test suite before merging.
The pseudocode for this workflow is as follows:
def run(goal, lead, workers, light):# 1. Planning: split into subtasks that do not conflictplan = lead.decompose(goal)results = []for task in plan:# 2. Dispatch: select the executing role based on routingtier = route(task)executor = {Tier.LEAD: lead,Tier.WORKER: workers,Tier.LIGHT: light,}[tier]# 3. Collection: return in a unified structure, escalate on failureresult = executor.execute(task)if not result.ok:result = lead.execute(task)results.append(result)# 4. Acceptance: the lead agent reviews all resultsreturn lead.review(goal, results)
5. Estimating Cost
Cost can be estimated with a simple formula:
Total cost = Σ (token usage of each role × relative unit price of that role) + coordination overhead
Coordination overhead is the token usage incurred when the lead agent decomposes tasks, aggregates results, and performs acceptance. This part is easy to underestimate, so it should be counted separately.
The following illustrative parameters are not measured data. They only show how the calculation works. Suppose a batch of tasks consumes 20 million input tokens. If the lead agent handles all of them, and its relative unit price is set to 20, the baseline cost is 20. After switching to tiered collaboration:
- The lead agent handles 4 million tokens at a relative unit price of 1, for a cost of 4.
- Execution workers handle 10 million tokens at a relative unit price of 0.3, for a cost of 3.
- Light workers handle 6 million tokens at a relative unit price of 0.1, for a cost of 0.6.
- Coordination overhead is 1 million tokens, priced at the lead agent’s unit price, for a cost of 1.
The total cost is 8.6, about 57% lower than the baseline of 20. Actual savings depend on the real price ratios between roles, the task distribution, and the rework rate. If rework increases noticeably after tiering, the savings shrink substantially. The rework rate must therefore be included in the evaluation.
6. Practical Considerations
- Context isolation: Workers receive only the files needed for their tasks, following the principle of least privilege. Unrelated code, configuration, and secrets should not enter their context.
- Output validation: Light worker results must pass structural validation and should not be used as facts directly. Classification conclusions in particular need regular sample-based review.
- Failure escalation: When a worker fails repeatedly, the task should escalate automatically to a higher-tier role instead of retrying indefinitely, which would consume a large number of tokens.
- Test safety net: Regardless of which role wrote the code, every change must pass the same automated test suite before merging.
- Concurrency control: The number of parallel workers is limited by API rate limits, repository conflicts, and review capacity. Do not scale it without bound.
- Data security: When using external services, confirm their data processing terms. Projects involving sensitive code should use a deployment method that meets the relevant compliance requirements.
7. Implementation Steps
- Inventory existing task types. Identify low-difficulty work such as search, extraction, and summarization, and estimate what share of total tokens it accounts for.
- Start with low-risk categories, such as log analysis and test result summarization. Assign only these tasks to light workers and observe
