# Complexity-Based Model Routing

When spawning an agent, pick a tier based on the request signals below, then pass `model` accordingly.

---

## Tier 1 — Haiku (fast/cheap)

**Signals:** single lookup, no code changes, classification, formatting, summarization, status check, documentation

**Examples:**
- "What's the status of X?"
- Summarize or format a session log
- Search/grep for a value
- Convert or extract data
- Write/update a markdown doc

**Agents that default here:** documentation-squire, explore (quick searches), photo

**Agent call:** `model: "haiku"`

---

## Tier 2 — Sonnet (default, inherit)

**Signals:** standard code generation, routine DB queries, test execution, API work, multi-file reads, git operations

**Examples:**
- Add or modify an endpoint
- Run tests and report results
- Write a DB migration
- Fetch credentials, configure a service
- Commit and push changes

**Agents that default here:** coding, database, testing, gitea, general-purpose, deep-explore (standard search)

**Agent call:** omit `model` (inherits session model)

---

## Tier 3 — Opus (high-stakes reasoning)

**Signals:** architectural decision, security/auth, 3+ interacting systems, ambiguous root cause, production data risk, anything that fails badly if wrong

**Examples:**
- Redesign an auth or data flow
- Security or code review of a critical PR
- Debug a multi-service race condition
- Schema migration on production data
- Evaluate competing architectural approaches

**Agents that default here:** code-review (when Sequential Thinking triggers), deep-explore (architecture questions)

**Agent call:** `model: "opus"`

---

## Bump Rule

If the request contains ANY of these keywords, bump one tier up regardless of other signals:

`security`, `auth`, `token`, `credential`, `migration`, `production`, `race condition`, `data loss`, `breach`, `encrypt`

---

## Quick Reference

| Tier | Model | Typical cost | Use when |
|------|-------|-------------|----------|
| 1 | `haiku` | ~10x cheaper | Lookup, format, summarize, doc |
| 2 | (inherit) | baseline | Standard code, DB, tests |
| 3 | `opus` | ~5x more expensive | Architecture, security, ambiguous failures |

Err toward Tier 2 when uncertain. Only use Opus when the reasoning stakes justify the cost.
