PTENES
MODULE 3.2 · Track 3 · Model, cost, and orchestration

💰 The real savings

Subagents cost money. But the expense doesn’t come from “using the expensive model” — it comes from using the expensive model in the wrong place. The secret is to assemble a team: a smart boss that thinks, and one low-cost fleet that does the heavy lifting.

6
Topics
~30
Minutes
Medium
Level
Theory+
Type

Think of a newsroom. The editor-in-chief doesn't rush after every source: it reads, decides the agenda, delegates, and wraps up the edition. The one who goes out into the field, transcribes interviews, and checks spelling is the team — good people, cheaper and more numerous. If the boss did everything, the payroll would explode and the newspaper would come out late. Subagents work the same way: let one expensive model for thinking and a low-cost fleet work. The savings don’t come from cutting quality—they come from put each model where it performs best.

Boss Opus · thinks and decides expensive · just 1 Haiku Haiku Haiku Haiku Haiku … low-cost fleet · many · in parallel Synthesis the boss wraps up

↑ The economics: one expensive lead decides, a fleet of cheap agents executes in parallel, and the lead wraps up the edit.

Detailed content

1

🏛️ The smart boss and the low-cost fleet

The money-saving design has two roles. At the top, an expensive model — Opus or Sonnet — which thinks: reads the problem, makes a plan, distributes the tasks, and brings it all together at the end. Underneath, a fleet of inexpensive models — Haiku — which does the heavy lifting: scans, searches, reads files, summarizes. You pay for the expensive once, for the hard part, and the cheap one often, for the mechanical part.

📰 The newsroom analogy

The editor-in-chief sets the agenda and closes the edition — they’re irreplaceable, but they’re just one. The reporting, transcription, and proofreading go to the team: inexpensive, numerous, fast. Nobody asks the editor-in-chief to transcribe two hours of audio. Subagents work the same way:

  • •Boss (Opus/Sonnet) = decides, plans, synthesizes. Expensive — use sparingly and wisely.
  • •Fleet (Haiku) = scans, searches, reads, summarizes. Inexpensive — use freely, in parallel.
  • •The error = making the boss do fleet work — or making the fleet decide.
What it is:

A hierarchical orchestration pattern: one strong model coordinates; many low-cost models handle most of the work in parallel.

Why learn:

It’s what separates “subagents are too expensive” from “subagents are cheap.” The math changes completely when the heavy lifting runs on the cheaper model.

Key concepts:

Hierarchical fan-out · lead (reasoning) × fleet (execution) · pay the high cost 1×, the low cost N×.

🧠
Boss
decides
🐝
Fleet
runs
⚡
Parallel
at scale
💵
Expensive 1×
N× cheaper
2

🎚️ The master key: CLAUDE_CODE_SUBAGENT_MODEL

You can set the model for each subagent one by one, in the field model from the file. But when you want the entire fleet run it cheaply all at once, there's a shortcut: the environment variable CLAUDE_CODE_SUBAGENT_MODEL. It defines the model default for all subagents that haven't pinned down their own model — without you touching each file.

in your terminal environment variable
# toda a frota de subagentes passa a rodar em Haiku
export CLAUDE_CODE_SUBAGENT_MODEL=claude-haiku-4-5

# abra o Claude Code já com a frota barata ligada
claude

# o chefe (a sessão principal) continua no modelo que
# você escolheu — só os subagentes herdam o Haiku.

🎯 Who's in charge of whom

  • model in the agent file — it always takes precedence (specific).
  • CLAUDE_CODE_SUBAGENT_MODEL — default for those that don’t have a fixed model.
  • inherit — with neither, the agent inherits the lead agent’s model.

💡 The house move

Keep the boss in Opus/Sonnet and throw the entire fleet in Haiku with the env var. One line, and the expensive part of the system becomes just the brain—not the muscle.

What it is: the variable that sets the default model for all subagents at once.
Why learn: is the fastest way to make the entire fleet cheaper without editing files one by one.
Key concepts: env var · precedence (model > env > inherit) · boss outside the variable’s reach.
3

🛑 maxTurns: the spending safety rope

The cost that should worry you isn’t the subagent that does the work — it’s the subagent that gets into a loop: tries, fails, tries again, and keeps running at your expense. The maxTurns is the cap on how many steps (tool turns) a subagent can take before stopping. It's a circuit breaker: when the limit is reached, shut it down—instead of burning tokens all night.

✗ No turn limit

  • ✗A stuck agent tries the same thing 40 times
  • ✗The bill goes up with no one watching
  • ✗The loop only shows up when the bill arrives

✓ With maxTurns

  • ✓Hits the limit, stops, and returns what it has
  • ✓Maximum spend per subagent becomes predictable
  • ✓The boss realizes it’s stuck and decides what to do next

📊 How to size the ceiling

A reading or summarization task usually wraps up in a few turns. If you expect ~10 steps, a limit of 15–20 provides some slack without leaving the loop unrestricted. The inexpensive fleet can have a low cap (simple task); the lead agent, which makes more back-and-forth trips, deserves a higher cap. No cap = open-ended bet.

What it is: the maximum number of turns a subagent can take before it is interrupted.
Why learn: is the defense against an agent in a loop running up uncontrolled costs—the worst kind of expense.
Key concepts: turn cap · cost circuit breaker · low cap for the fleet, higher for the lead.
4

📈 Multi-agent costs ~15× — and when it’s worth it

There's no magic: running a fleet of subagents consumes many more tokens that a single conversation — in the order of ~15×. Each subagent starts from scratch and gathers its own context before producing. This isn't a waste automatic: that's the price of parallelism and clean context. The right question isn't "is it expensive?", but "what do I get that makes this 15× worthwhile?".

relative token consumption (illustrative)
1 single conversation1×
multi-agent fleet~15×
↑ 15× more tokens — only worth it when the work is truly large, noisy, or parallelizable.

↑ Illustrative recreation, not an actual measurement. The proportion is there to establish the order of magnitude.

✓ When 15× is worth it

  • ✓The work is large (dozens of files, lots of reading)
  • ✓The material is noisy and you just want the clean conclusion
  • ✓You can parallelize and save wall-clock time
  • ✓Protect the your context is worth the extra token cost

✗ When it’s just waste

  • ✗A 30-second edit in a single file
  • ✗Something that depends on the entire conversation that you already have
  • ✗Small task, no heavy reading or parallelism
  • ✗Pay 15× to assemble context that was already at your fingertips
What it is: the order of magnitude of the cost of a multi-agent fleet compared with a single conversation.
Why learn: to decide with your eyes open — know the price and choose to pay it when, and only when, it's worthwhile.
Key concepts: ~15× tokens · each agent gathers context · large/noisy/parallel × quick edit.
5

🧩 Combine well > spend a lot

The wrong instinct is "if it’s expensive, I need a stronger model." Almost never. The real gains come from combine: the right model for the right role, the right limit, the right parallelism. A well-orchestrated Haiku fleet led by a Sonnet chief delivers more for less than everything in Opus. Architecture beats brute force.

smart boss Opus/Sonnet + low-cost fleet Haiku · parallel + turn caps maxTurns = good, low-cost delivery architecture > brute force

💡 Before scaling up the model, adjust the design

Did it get stuck or become expensive? Before switching everything from Haiku to Opus, ask: can you parallelize? O briefing is clear (fewer back-and-forths)? The cap is suffocating a task that needed more? Most of the time the problem is architecture, not the model.

What it is: the principle that combining resources judiciously delivers more than forcing the model to scale up.
Why learn: avoids the expensive, lazy solution of "put everything on Opus" when the bottleneck is orchestration.
Key concepts: combination (model+limit+parallelism) · architecture > brute force · adjust the design before the model.
6

🔭 Measure and observe: you can't cut what you can't see

Real savings require look at the cost. How much did each subagent use? Which one hit the limit? Where did the time go? Without monitoring, you're optimizing in the dark — cutting what was cheap and leaving the expensive one running. Measure first, adjust later: that's how the boss/fleet split stops being a guess and becomes a number.

1

Observe a real run

Run the work as it is today.

See by subagent: model used, tokens consumed, turns spent, who hit the limit.

2

Find the offender

Spending is rarely distributed evenly.

Almost always, an expensive agent doing fleet work or an unbounded loop accounts for most of the bill.

3

Adjust one parameter and measure again

One change at a time.

Download an agent model, set a cap, parallelize — and compare the new run with the previous one. Repeat.

What it is: the habit of measuring subagent usage and adjusting the design based on what you observe.
Why learn: optimizing without measuring is guesswork; with measurement, each cut targets the cost that actually matters.
Key concepts: observability · find the offender · measure → adjust a parameter → measure again.
📄

Real example: a fleet agent with model + maxTurns

The two controls in this module fit in the frontmatter of a single file .md: model says who does (cheap model), and maxTurns says how far it can come before stopping. This log-scanner.md is a typical fleet worker: cheap, read-only, with a cap.

.claude/agents/log-scanner.md Markdown + YAML
--- # frontmatter: a CONFIGURAÇÃO do subagente
name: log-scanner             # minúsculas e hífens
description: Vasculha logs e arquivos grandes em
  busca de erros e devolve só um resumo. Use para
  varreduras pesadas.          # o GATILHO
tools: Read, Grep, Glob       # só leitura: trabalho de frota
model: haiku                  # BARATO — é a frota, não o chefe
maxTurns: 12                  # TETO — disjuntor contra loop
---

# corpo: o CÉREBRO do subagente
You are a fast log scanner.

When invoked:
1. Grep the given files for errors and warnings.
2. Group what you find by type and file.
3. Stop as soon as you have the summary.

Return: a short report — counts per error type
and the 3 files with the most issues. Nothing else.
Do not open files line by line; do not loop.

💵 model: haiku

  • It’s the fleet — a mechanical scanning task.
  • Cheap per call — can run in parallel, at scale.
  • The environment variable takes precedence — the fixed model in the file takes precedence.
  • Read-only — with no write tool, no damage.

🛑 maxTurns: 12

  • Step limit — stop even if it hasn’t “finished.”
  • Short on purpose — scanning doesn't need many turns.
  • Predictable cost — maximum known cost per call.
  • Kills the loop — the worst-case bill never happens.
⌨️

Ready-made prompts (copy and paste)

Three prompts to apply these savings now: turn on the low-cost fleet, set a cap to prevent loops, and map out the lead/fleet split before spending. Notice the pattern: right model for the right role, with limit.

Prompt 1 — low-cost fleet by default CLAUDE_CODE_SUBAGENT_MODEL
Quero que toda a frota de subagentes rode em Haiku,
mas que você (o chefe) continue em Sonnet. Me mostre
como ligar isso com CLAUDE_CODE_SUBAGENT_MODEL e
confirme quem ficou em qual modelo.
Prompt 2 — add a loop limit maxTurns
Crie um subagente de varredura de logs em Haiku,
read-only, com maxTurns 12 para ele não entrar em
loop. Quero o arquivo .md pronto, com model e maxTurns
no frontmatter.
Prompt 3 — design the split before spending boss × fleet
Para este trabalho [descreva], me proponha a divisão
chefe/frota: o que fica no modelo caro (decidir/juntar)
e o que vai para a frota Haiku em paralelo. Diga qual
modelo e qual maxTurns para cada papel — e por quê.
🖥️

Simulated screen: the fleet cost dashboard

This is how the savings show up when you observes: o boss in Opus barely does any work, because it only thinks; the Haiku fleet does the heavy lifting for a fraction of the cost; and there's a warning where an agent touched the maxTurns. This is the diagram that shows where cut — before guessing.

claude code · /cost · fleet running ⏱ 01:12
★ boss (session)Opus
~38k tok
● scanner-logs #1Haiku
~9k tok
● scanner-logs #2Haiku
~7k tok
● grep-massa #3Haiku
~11k tok
● doc-reader #4Haiku
maxTurns!
4 Haiku subagents · 1 hit the limit (12 turns) and stopped — without becoming a loop.
96% of tokens on the low-cost fleet · 14% on the lead
spending distribution healthy

↑ Illustrative recreation of the cost panel (not a real screenshot). The lead thinks for a little while; the fleet carries the workload — and the cap stopped the stuck agent.

🎯

Exercise

Choose a real task you'd handle with subagents (e.g., "audit 50 log files from the last deploy"). Draw the commander/fleet division: what stays with the expensive model, what goes to the low-cost fleet, and what cap each one takes.

How to do it

  1. Write the work in one line and separate decide/bring together (manager) of read/search/summarize (fleet).
  2. For each part, choose a model (Opus/Sonnet for the manager; Haiku for the fleet) and justify your choice.
  3. Define a maxTurns by role (short in the fleet, broader in the lead agent) and say how you'd connect the cheap fleet (env var or model in the file).

✅ Verification criteria — how to know you got it right

Your design passes if it meets the four points:

  • →The expensive one only thinks: the powerful model appears only for deciding, planning, and synthesizing, never for raw scanning.
  • →The fleet is Haiku and parallel: the heavy lifting is done by the cheap model and can run at scale.
  • →Every agent has a limit: no role is left without maxTurns — short on the fleet, longer on the boss.
  • →The 15× is justified: you can say in one sentence why it’s worth paying for multi-agent in this case (large/noisy/parallel).

If the task is small and the 15× no if that’s justified, the right answer is don't use a fleet — and noticing that also counts as a success.

Solved example

Work: "audit 50 deploy logs and tell me the 3 most frequent errors". Boss (Sonnet): divides the 50 into batches, combines the summaries, and ranks the errors — maxTurns 25. Fleet (Haiku, ~5 in parallel): each one scans a read-only batch and returns the count — maxTurns 12. Is 15× justified? Yes: 50 files, noisy material, parallelizable — I only want the clean ranking.

✅ Module summary

✓
Boss + fleet — an expensive model thinks (Opus/Sonnet); a cheap fleet (Haiku) does the heavy lifting in parallel.
✓
CLAUDE_CODE_SUBAGENT_MODEL — one env var downgrades the whole fleet to Haiku at once; model in the file always takes precedence.
✓
maxTurns — the circuit breaker: a step limit that kills loops and makes per-agent spending predictable.
✓
~15× and when it’s worth it — multi-agent costs much more; it's only worth it for large, noisy, or parallel work.
✓
Combine > spend — a well-balanced model+cap+parallelism delivers more than putting everything on Opus.
✓
Measure and observe — check the cost per subagent, find the offender, adjust one parameter, and measure again.

Next module:

3.3 — Chaining subagents. The conductor coordinates A→B→C; agents don’t call agents, and the sequence stays in the boss’s hands.