Sub topic 14
Cost and latency trade-offs
This chapter assumes you have read the chapters on the orchestrator-worker pattern and on parallel versus sequential execution. It also assumes you know that model usage is billed in tokens, which are the units of text a model reads and writes.
Where the cost comes from
Subagents do not make work cheaper. They usually make it more expensive, and they can make it finish sooner. Every subagent pays for things a single agent pays for only once:
- The system prompt and tool definitions, sent at the start of every subagent run.
- The delegation brief, which the orchestrator writes as output tokens and the subagent then reads as input.
- Repeated exploration. Two subagents that both need
src/cli.pyeach read it. - The returned summary, which the orchestrator reads and may need to check.
The saving is that each subagent's long tool output stays out of the parent's context. The parent's context stays small, so the parent's later turns are cheaper and less likely to lose track of earlier details.
Where the latency comes from
Wall-clock time depends on how you run the tasks. Sequential runs take the sum of the task times. Parallel runs take about the longest task, plus the overhead of starting workers and merging results.
def wall_clock(durations: list[float], parallel: bool, overhead: float = 0.5) -> float:
"""Estimate minutes for a set of subagent tasks."""
if not durations:
return 0.0
base = max(durations) if parallel else sum(durations)
return base + overhead
tasks = [4.0, 6.0, 5.0] # minutes per subagent
print(wall_clock(tasks, parallel=False)) # 15.5
print(wall_clock(tasks, parallel=True)) # 6.5Parallelism cuts time here from 15.5 minutes to 6.5. Token use stays the same or grows, because every worker still does its full job.
Comparing the options
| Factor | Single agent | Subagents in parallel |
|---|---|---|
| Total tokens | Lowest | Higher, from repeated setup and reading |
| Wall-clock time | Sum of all work | Longest task plus merge |
| Parent context growth | Fast | Slow, only summaries return |
| Review effort | One change set | Several change sets to check |
| Concurrent model calls | One | Several, which can hit rate limits |
Practical rules
- Delegate when a task produces a lot of intermediate output you do not need to keep, such as searching a large codebase or running a long test suite.
- Run in parallel only when tasks are independent. Parallel tasks that conflict create merge work that cancels the time saved.
- Skip delegation for small tasks. If the brief takes longer to write than the task takes to do, do the task directly.
- Set a timeout and a cap on turns or tokens per subagent. A stuck worker otherwise keeps spending money.
- Choose the model per task. Routine edits or file searches often work on a smaller, cheaper model, and design decisions may need a stronger one.
- Count review time. A fast parallel run still costs you minutes if you must read three separate diffs.
Exercise
Three independent subagent tasks take 3, 8 and 5 minutes. Merging takes 1 minute in total. Ignoring other overhead, how long does a sequential run take, and how long does a parallel run take? Does the parallel run use fewer tokens?
Show answer
Sequential: 3 + 8 + 5 = 16 minutes, plus 1 minute to merge, so 17 minutes. Parallel: the longest task is 8 minutes, plus 1 minute to merge, so 9 minutes. The parallel run does not use fewer tokens. Each worker does the same work, and the extra setup and briefs add some tokens. It saves time, not tokens.