D1 · Agentic Architecture › Cluster 7 · Performance

7.1 · Model Selection per Role

Match the model to the task's difficulty

CONCEPT Three models, one rule

Every request in an agentic system carries a model choice, and that choice is your single biggest cost/latency lever. The rule is simple and the exam tests it relentlessly: match the model to the difficulty of the task — don't pay Opus prices for a Haiku-shaped job, and don't starve a hard reasoning task on Haiku.

ModelWhen to reach for itPrice (per 1M in / out)
claude-opus-4-8 Default. Hardest reasoning & agentic work — the orchestrator, tricky multi-step planning, ambiguous tasks. $5 / $25
claude-sonnet-4-6 Best speed/intelligence balance. High-volume work that still needs solid reasoning; most production request paths. $3 / $15
claude-haiku-4-5 Fastest & cheapest. Simple, well-scoped, or parallel sub-tasks — classification, extraction, routing, fan-out workers. $1 / $5
🔑 Use the exact model ids — claude-opus-4-8, claude-sonnet-4-6, claude-haiku-4-5. Never append a date suffix; the model id is the id.
💡 Output tokens cost ~5× input across all three tiers. A model that produces a tight answer can be cheaper than a "cheaper" model that rambles — measure real cost/run (see 7.6), not just the sticker price.

DIAGRAM Per-role selection in a multi-agent system

The classic pattern: an Opus orchestrator plans and delegates; Haiku workers fan out over simple parallel sub-tasks; a Sonnet role handles the high-volume middle.

flowchart TD U([User task]) --> O["🟣 Orchestrator
claude-opus-4-8
plan · decompose · synthesize"] O --> W1["🟢 Worker
claude-haiku-4-5
fetch page 1"] O --> W2["🟢 Worker
claude-haiku-4-5
fetch page 2"] O --> S["🔵 Summarizer
claude-sonnet-4-6
high-volume merge"] W1 --> O W2 --> O S --> O O --> A([Final answer]) classDef opus fill:#e2d4f0,stroke:#764ba2,color:#3d1a5b; classDef son fill:#d1ecf1,stroke:#17a2b8,color:#0c5460; classDef hai fill:#d4edda,stroke:#28a745,color:#155724; class O opus; class S son; class W1 hai; class W2 hai;

CODE Choosing a model per role

Because POST /v1/messages is stateless, the model is just a per-request parameter — nothing stops you from mixing tiers across one logical run. Keep the mapping in one place so roles, not call sites, decide the tier.

# One source of truth: role → model. Match model to task difficulty.
MODEL_FOR = {
    "orchestrator": "claude-opus-4-8",    # hardest reasoning / planning
    "summarizer":   "claude-sonnet-4-6",  # high-volume, balanced
    "extractor":    "claude-haiku-4-5",   # simple, parallel sub-task
}

def run_role(role, prompt, max_tokens=1024):
    # The model is a per-request param — the API is stateless, so mixing tiers is free.
    return client.messages.create(
        model=MODEL_FOR[role],
        max_tokens=max_tokens,
        messages=[{"role": "user", "content": prompt}],
    )

plan     = run_role("orchestrator", task, max_tokens=4096)   # Opus
fields   = run_role("extractor", page_text)                 # Haiku, cheap fan-out
digest   = run_role("summarizer", joined_results)          # Sonnet

TRADE-OFFS Cheaper model vs. stronger model

✅ Drop to Haiku / Sonnet when…

  • The sub-task is simple, scoped, or highly parallel
  • Volume is high and per-call quality tolerance is generous
  • Latency matters more than deep reasoning

⚠️ …but a too-weak model can cost more

  • Retries, longer outputs, and failed runs erase the savings
  • An under-powered orchestrator makes bad tool decisions
  • Resolution rate (7.6) drops — the real cost metric
Rule of thumb: start on Opus, then down-tier the roles that measurably tolerate it. Prove a cheaper model holds quality before you standardize on it.

EXAM TRAPS

Trap: "Use the cheapest model for the orchestrator." → No. The orchestrator does the hardest reasoning; put Opus there and save cost on the simple workers.
Trap: Writing claude-opus-4-8-20250101 or similar. → The exact id has no date suffix; a dated id is wrong.
Trap: Assuming one model must serve the whole run. → The Messages API is stateless; the model is per-request, so you can mix tiers by role freely.
Trap: Ranking models by input price alone. → Output tokens dominate (~5×), and a weaker model that rambles or retries can be the more expensive choice.

PRACTICE

Q1 · A pipeline fans out 500 independent "extract the date from this line" calls, then does one hard synthesis. How do you assign models?

The 500 extractions are simple and parallel → claude-haiku-4-5. The single hard synthesis needs the strongest reasoning → claude-opus-4-8. This is the orchestrator+workers shape: cheap fan-out, strong center.

Q2 · Your team wants "one model for everything" to simplify ops. What's the architect's response?

The API is stateless, so per-request model choice costs nothing operationally — centralize the role→model map in one place instead. Uniform Opus overpays on simple work; uniform Haiku starves hard tasks. Match model to task difficulty per role.

Q3 · Which model is the documented default when you're unsure?

claude-opus-4-8. Start there for the hardest reasoning and agentic work, then down-tier roles that measurably tolerate a cheaper model.