PTENES
Track 3 Subagents Course

Model, cost, and orchestration

Choose the right model for each task, control multi-agent costs, and master coordination patterns that scale to dozens of subagents.

Orchestrator chooses the model Haiku · scanning Haiku · reading Sonnet · review Sonnet · coding Opus · decisions Result controlled cost
6
Modules
36+
Topics
~3h
Duration
Medium
Level

Learning path map

Detailed content

3.1 ~30 min

🎯 Model by task

Haiku, Sonnet, and Opus have different costs and capabilities. Knowing when to use each one is the difference between an economical system and an unnecessarily expensive one.

What it is:

Haiku is the fastest and least expensive model in the Claude family. Ideal for repetitive, low-reasoning tasks: reading files, searching for patterns, summarizing short passages, and running commands.

Why learn:

Most subagents in a fleet don’t need deep reasoning. Using Haiku for them reduces the total cost by up to 10×. Choosing Opus for scanning is a budget mistake, not a quality mistake.

Key concepts:

Very low cost per token; lower latency; own context (starts from scratch); does not inherit the orchestrator’s reasoning — receives explicit instructions.

What it is:

Sonnet balances reasoning ability and cost. Excellent for writing code, reviewing PRs, synthesizing results from other subagents, and making intermediate decisions.

Why learn:

It’s Claude Code’s default model. In most workflows, Sonnet handles the “middle”: it receives raw data from Haiku and delivers refined material for Opus to evaluate.

Key concepts:

Great for code generation and synthesis; medium cost; used as the conductor in mid-sized pipelines; replaces Opus in 80% of cases with no noticeable loss.

What it is:

Opus has the deepest reasoning. Reserved for architectural decisions, security assessments, long-term synthesis, and situations where mistakes are costly.

Why learn:

Using Opus across the entire fleet multiplies the cost by 5–20×. Knowing how to identify the moments when only Opus will do (and those that don’t need it) is the central skill in this track.

Key concepts:

High cost; higher latency; better for multistep reasoning; use as the fleet lead for Haiku/Sonnet; never in the inner loop of cheap subagents.

What it is:

Every subagent starts with clean context. It doesn’t know what you just discussed — it needs complete instructions in its description and in the conductor’s messages.

Why learn:

A well-instructed Haiku outperforms a poorly instructed Opus. The chosen model only matters after the instructions are correct. The “trap” is paying more and expecting the model to guess the context.

Key concepts:

No history inheritance; the conductor passes the necessary context via a message; CLAUDE_CODE_SUBAGENT_MODEL overrides the fleet’s default model.

What it is:

A simple heuristic: Haiku for “read and report,” Sonnet for “build and review,” Opus for “decide and architect.” Apply it to tasks before coding the subagent.

Why learn:

Model assignment errors are invisible — the result looks the same, but the cost is 5–10× higher. Having the table committed to memory prevents automatic decisions to "use the most capable model".

Key concepts:

Haiku: search, reading, extraction, summarization. Sonnet: writing, code, synthesis, review. Opus: architecture, security, final evaluation, deep reasoning.

What it is:

Given a hypothetical pipeline with 6 tasks (scan logs, write tests, review a PR, propose architecture, look up docs, assess security), assign the right model to each.

Why learn:

The attribution exercise reinforces the heuristic. Getting it wrong in an exercise is cheap; getting it wrong in a real system with 100 subagents is costly.

Key concepts:

Evaluation criterion: estimated cost × expected quality. An annotated answer key is in the full module.

View Full
3.2 ~30 min

💰 The real savings

Multiagent costs ~15× more than a simple chat. Understanding why and how to control this is what separates prototypes from sustainable systems.

What it is:

Each subagent has its own context, system prompt, and round trip to the API. With 10 subagents running in parallel, the number of tokens consumed multiplies quickly.

Why learn:

Without this awareness, it’s easy to create workflows that cost tens of dollars per run. Knowing the multiplier lets you plan ahead—and know when multi-agent is worth the price.

Key concepts:

Cost per run = (input + output tokens) × price × number of subagents; system prompt repeated per agent; context passed by the orchestrator counts too.

What it is:

The boss (Opus or Sonnet) orchestrates the work: decides on a strategy, breaks down tasks, and evaluates results. The fleet (Haiku) executes in parallel: reads, searches, extracts, and reports.

Why learn:

It’s the best value pattern: one expensive agent makes the smart decisions while many cheap agents do the mechanical work. Quality goes up; average cost per result goes down.

Key concepts:

1 boss, N workers; the boss evaluates and consolidates; workers report back; the decision of "what to do" stays with the boss, "how to do it" with the fleet.

What it is:

An environment variable that forces all subagents to use a specific model, regardless of the system default. Useful for controlling costs in large batches.

Why learn:

Without this variable, subagents use the default model—which may be Sonnet or Opus. With it, you ensure the entire fleet uses Haiku without changing each agent’s code.

Key concepts:

`CLAUDE_CODE_SUBAGENT_MODEL=claude-haiku-4-5` in the environment; overrides only subagents (the main agent keeps the original model); useful in high-scale workflows.

What it is:

A parameter that limits how many back-and-forth rounds a subagent can make. Each turn consumes tokens. Without a limit, an agent stuck in a loop can spend indefinitely.

Why learn:

Subagents occasionally get caught in trial-and-error loops. With `maxTurns` set, the maximum cost per run is predictable — and the agent fails in a controlled way instead of silently spending more.

Key concepts:

Configured in the subagent's CLAUDE.md or via the SDK; typical value: 10–20 turns; after the limit, the agent returns what it has so far.

What it is:

Objective criteria for deciding: parallel tasks that would each take 10+ min sequentially; jobs with an "output wall" that would cause truncation in a single context; codebase with 10+ interdependent files.

Why learn:

Using multi-agent for small tasks is like paying 15× for 0% real gain. A clear criterion avoids that waste and justifies the cost when the task really requires it.

Key concepts:

Positive signal: genuine parallelism, context separation, large output. Negative signal: short sequential task, need for shared context, simple result.

What it is:

Given a repository analysis job (identify code smells in 50 files), design the division: which agent is the lead, how many workers, which model for each role, and how the results are consolidated.

Why learn:

Designing before implementing avoids costly redesigns. The exercise makes you think about task granularity, estimated cost, and failure points.

Key concepts:

Deliverable: a simple diagram (structured text is fine) showing roles, models, data flow, and estimated cost per run.

View Full
3.3 ~35 min

🔗 Chaining subagents

The conductor coordinates A→B→C. Skills and agents can call each other; agents, however, never call other agents. Understanding this rule prevents architectures that Claude doesn’t support.

What it is:

The orchestrator is the main agent that receives the user’s task, breaks it down into subtasks, and dispatches each one to a subagent. It waits for the results, consolidates them, and delivers the final answer.

Why learn:

Without an explicit conductor, there’s no coordination—the subagents don’t “talk” to one another. Recognizing the conductor as the single point of orchestration is central to workflow design.

Key concepts:

Star topology: conductor at the center, subagents at the endpoints; the conductor explicitly passes context to each subagent; results return to the conductor and never circulate between subagents.

What it is:

One agent (CLAUDE.md) cannot invoke another agent directly. Invocation happens through a skill (which can call agents) or through Claude Code itself when it runs a higher-level workflow.

Why learn:

Designing an agent that tries to call another agent results in an execution error or undefined behavior. Knowing this limit helps you avoid impossible architectures and points to the right approach (through a skill).

Key concepts:

Agent calls a skill; skill calls an agent; agent does not call an agent. The control loop always stays in the main Claude Code session or an orchestrating skill.

What it is:

A skill (an instruction `.md` file) can contain logic that triggers multiple agents in sequence or in parallel. This is the right pattern for creating complex pipelines without violating the agents-don’t-call-agents rule.

Why learn:

Skills are the “glue” of the ecosystem. Understanding how a skill launches agents lets you build workflows with N steps without needing a special orchestration agent.

Key concepts:

Skill = instruction to Claude Code; Claude Code runs the invoked agent; the skill defines the logical sequence; intermediate state can be passed via files or messages.

What it is:

When the result from A is needed for B to start, and the result from B is needed for C to start, you have a sequential pipeline. The conductor waits for each step before triggering the next.

Why learn:

Mixing sequential and parallel work without realizing it creates race conditions or incorrect results. Identifying dependencies between tasks is the first step in designing any pipeline.

Key concepts:

Data dependency = sequential; independence = parallel; the orchestrator decides the order based on dependencies; pass A’s output as B’s input via a message or file.

What it is:

Each subagent communicates only with the conductor that invoked it. There is no side channel between subagent A and subagent B. For A to “pass something” to B, the conductor has to relay it.

Why learn:

Projects that assume direct communication between subagents don’t work. Knowing this limit before designing helps you avoid architectures that look elegant on paper but are impossible in practice.

Key concepts:

Maestro is the only integration point; “conversations” between subagents are an illusion — the maestro mediates; use shared files when two agents need the same data.

What it is:

Design (in text or a diagram) a 3-step pipeline for the job: “find open issues → prioritize by impact → draft triage comments.” Identify which steps are sequential and which can run in parallel.

Why learn:

The ability to break a job into steps with clear dependencies is the foundation of any orchestration. Getting this wrong is the most common mistake people make when starting with multi-agent systems.

Key concepts:

Deliverable: a diagram with directional arrows, selected models, handoff points, and a data transfer mechanism (message or file).

View Full
3.4 ~30 min

🔍 The impartial reviewer

Fresh context = honest verdict. Whoever built the artifact should not be the one to validate it—separating builder and reviewer roles is the most powerful quality control practice in multi-agent work.

What it is:

The agent that built an artifact carries the entire history of decisions that led to that result in its context. This context induces confirmation bias — it tends to validate what it has already decided.

Why learn:

A reviewer with clean context has no access to the “why” behind the decisions — they see only the result. That isolation leads to more objective criticism and identifies problems the builder overlooked.

Key concepts:

Clean context = starts from scratch; doesn't inherit the builder's "internal logic"; receives only the artifact + evaluation criteria; produces feedback without anchoring to the original decisions.

What it is:

The builder receives the task and produces the artifact (code, plan, research). The reviewer receives the artifact + criteria and produces a quality report. They are two distinct subagents, called in sequence by the conductor.

Why learn:

Separating roles improves quality without increasing the complexity of each individual agent—each one does one thing and does it well. The conductor decides whether the feedback calls for another builder iteration.

Key concepts:

Flow: conductor → builder (produces) → conductor → reviewer (critiques) → conductor (decides whether to iterate or publish); the reviewer has no access to the builder's internal process.

What it is:

The builder-reviewer pattern works for any type of artifact: code (the reviewer checks for bugs and style), a plan (the reviewer checks feasibility and risks), research (the reviewer checks sources and consistency).

Why learn:

Recognizing that the same pattern applies across different domains lets you reuse the same orchestration architecture — only the criteria given to the reviewer change, not the pipeline.

Key concepts:

Explicit criteria in the reviewer prompt; domain-specific (code: correctness, style; plan: feasibility, risk; research: sources, consistency); the reviewer delivers a structured report.

What it is:

`plan-roaster` and `code-reviewer` are subagents available in the Claude Code ecosystem that implement the reviewer pattern. They are concrete examples to study and adapt.

Why learn:

Studying an existing reviewer reveals how the criteria are passed, how the output is structured, which model to use for review, and how the orchestrator uses the result. It’s faster than designing from scratch.

Key concepts:

Reviewer receives: artifact + criteria + scope; produces: report with findings categorized by severity; the orchestrator decides what to do based on the report.

What it is:

After the reviewer delivers the report, the conductor decides: are the findings critical (another builder iteration) or acceptable (publish)? This loop can repeat 2–3 times before reaching a stopping criterion.

Why learn:

Without a stopping criterion, the loop can run indefinitely. Defining “when it’s good enough” before execution is just as important as designing the agents.

Key concepts:

Stop criterion: zero critical findings, or N iterations reached, or cost deadline; the orchestrator encodes the criterion; the reviewer reports severity to make the decision easier.

What it is:

Use the pipeline diagram you created in M3.3 as an artifact. Give it to a reviewer (you can be the reviewer yourself with “clean context,” or use a code-reviewer subagent) with these criteria: feasibility, efficiency, failure points.

Why learn:

Reviewing your own work with an outside perspective (even a simulated one) is the meta-quality skill. This exercise closes the M3.3 → M3.4 loop: you built it, and now you evaluate it.

Key concepts:

Deliverable: a report with findings (at least 1 improvement identified); reflect on what you would change in the M3.3 diagram after the review.

View Full
3.5 ~25 min

⚡ Dynamic workflows

With the `ultracode` trigger, dozens or hundreds of subagents can be launched in a single session. The power is real — and so is the cost. Knowing when to pull that lever is the point of this module.

What it is:

`ultracode` (previously called "workflow") is the trigger that instructs Claude Code to operate in high-scale mode: it breaks the job into dozens of parallel tasks and launches subagents for each one.

Why learn:

Activating `ultracode` for small jobs wastes budget. Knowing what the trigger does under the hood lets you use it surgically — only when the scale justifies it.

Key concepts:

Automatic planning mode + aggressive parallelization; Claude Code estimates the number of subagents before execution; you can confirm or cancel; estimated cost is visible before the commit.

What it is:

Documented real case where a single job launched 41 subagents in parallel to refactor a large repository. The result was delivered in a fraction of the time it would have taken sequentially.

Why learn:

The concrete case grounds the concept: this isn’t theory. It shows what’s possible, what the actual cost was, and what worked and what problems came up during large-scale execution.

Key concepts:

41 Haiku subagents; Sonnet orchestrator; task: refactor 80+ files; estimated cost: ~$8 per run; total time: ~6 min vs. ~2h sequentially; test coverage maintained.

What it is:

Sessions with dozens of subagents consume tokens quickly. API rate limits and Claude Code session limits can interrupt a workflow midway.

Why learn:

Not planning the budget before an ultracode leads to incomplete jobs and wasted costs. Understanding the limits lets you size the job correctly — or split it into smaller batches.

Key concepts:

Rate limits per minute and per day; Claude Code session limit (tokens per window); batching strategy: split into groups of 10–20 subagents to stay within the limits.

What it is:

Practical checklist: 10+ files to modify, genuinely parallel tasks (with no dependencies on one another), expected output that would cause truncation in a single context, large-scale refactoring, parallel analysis of multiple modules.

Why learn:

The checklist prevents decisions based on intuition. With it, you can reach a "yes/no for workflow" in 30 seconds, before running anything.

Key concepts:

Any strong “yes” on the checklist points to a workflow; red flags: small task, shared context needed, interdependent results; when in doubt, don't use a workflow.

What it is:

In workflows with 40+ subagents, partial failures are expected. The orchestrator needs to detect which subtasks failed and decide whether to retry, ignore, or abort the entire job.

Why learn:

Jobs without a recovery strategy fail completely when any subagent fails. Designing failure handling before execution reduces rework costs and increases robustness.

Key concepts:

Log results by subagent; identify failures by ID; use a “retry once, then skip” strategy; the orchestrator consolidates results, marking them incomplete where needed.

What it is:

Given 3 scenarios (A: refactor 1 file; B: analyze 100 closed PRs; C: write tests for 15 modules), apply the checklist and answer: workflow or not? Justify each decision.

Why learn:

Practicing binary decisions with justification is the module’s key skill. Answers without justification don’t count—the reasoning is the deliverable, not the yes or no.

Key concepts:

Answer key: A = no (single file); B = yes (100 independent parallel tasks); C = yes (15 separable modules); the full module includes a detailed analysis of each case.

View Full
3.6 ~30 min

🗺️ Orchestration patterns

Independent parallelism, sequential pipeline, or fan-out? Each topology has different use cases, advantages, and costs. This module wraps up the learning path with a complete map of the options.

What it is:

N subagents running at the same time, each with its own isolated task and no dependencies between them. The orchestrator launches them all and waits for them all to finish before consolidating.

Why learn:

It’s the most efficient pattern for uniform tasks at scale: analyze N files, search N documents, generate N drafts. Recognizing when tasks are genuinely independent is a prerequisite.

Key concepts:

Full independence: no subagent needs another’s results; the orchestrator syncs at the end; cost = N × individual cost; speedup = N× (limited by the rate limit).

What it is:

Stages A → B → C, where each stage’s output is the next stage’s input. The orchestrator runs them one at a time, waiting for each result before proceeding.

Why learn:

For tasks with data dependencies, the pipeline is the only correct pattern. Forcing parallelism where there are dependencies leads to errors or inconsistent results—recognizing dependencies is essential.

Key concepts:

Total latency = sum of individual latencies; there’s no speedup from parallelism; each step can use a different model (e.g., Haiku collects, Sonnet synthesizes, Opus decides).

What it is:

1 input → N parallel subagents → 1 aggregated result. The conductor launches N workers with different parts of the problem, waits for everyone, and passes the N results to an aggregator that synthesizes the final result.

Why learn:

Fan-out is the ultracode pattern. Understanding the "dispatcher → workers → aggregator" structure lets you design any high-scale workflow and understand what Claude Code does under the hood when you use ultracode.

Key concepts:

Dispatcher: the conductor that splits the input; workers: Haiku/Sonnet in parallel; aggregator: a separate agent (Sonnet/Opus) that consolidates; final result: one, coherent, complete.

What it is:

Agent teams are configurations where multiple agents share context and communicate directly — unlike classic subagents with a star topology. They cost more because they keep multiple contexts open.

Why learn:

Knowing the difference helps you avoid confusing the two architectures. Agent teams are rare in Claude Code and generally more expensive and complex. For most cases, subagents with a central orchestrator are more efficient.

Key concepts:

Subagents: star topology, central conductor, isolated contexts, lower cost. Agent teams: communication graph, partially shared contexts, higher cost, less common.

What it is:

Practical rule of thumb: if the job involves 10+ separable files OR would produce output that would be truncated in a single context, use fan-out or parallel processing. Otherwise, use a sequential pipeline or a single agent.

Why learn:

Having a numerical heuristic avoids detailed analysis for every job. "10 files" is the practical threshold derived from real-world experience — below that, the multiagent overhead generally isn't worth it.

Key concepts:

10 files = ~threshold for overhead; "output wall" = a result that would use > 50% of the context; both are indicators, not absolute rules; the operator makes the final call.

What it is:

Given 3 problems (A: translate 30 Markdown files; B: generate release notes from 50 commits analyzed in order; C: review code + propose a refactor + implement it), choose the topology and justify it.

Why learn:

The exercise wraps up the path: you apply topology vocabulary to real problems. Answer key: A = independent parallel; B = fan-out + pipeline (parallel collection, sequential synthesis); C = pipeline (3 dependent stages).

Key concepts:

Deliverable: a problem × topology × rationale × selected models table. The full module includes a reference implementation for each case.

View Full