Model routing and subagent delegation patterns. Teaches when to work inline vs spawn subagents, and which model tier + agent type to use.
Route tasks to the appropriate model tier and execution mode. Most work should happen inline in the main conversation. Spawn subagents only when there's a clear benefit.
Spawn a subagent via the Task tool ONLY when:
For everything else, work inline. Inline is faster (no startup overhead) and cheaper (~4x fewer tokens than a subagent).
| Task Class | Model | Agent Type | Key Skills to Reference |
|---|---|---|---|
| Quick triage, simple Q&A |
| haiku |
| Explore |
| -- |
| Codebase exploration | haiku | Explore | -- |
| Standard planning, task breakdown | sonnet | general-purpose | planning, arch-core |
| Architecture design, deep research | opus | general-purpose | architecture-design, go-arch, go-api |
| Code implementation | sonnet | general-purpose | go-code |
| Write/fix tests | sonnet | general-purpose | go-test |
| Standard debugging | sonnet | general-purpose | debug-core, go-test |
| Complex debugging (concurrency, perf) | opus | general-purpose | debug-core, go-perf, go-concurrency |
| Code review | opus | Explore | go-review, security-core |
| Acceptance validation | opus | Explore | acceptance |
| API/endpoint testing | sonnet | general-purpose | qa-api |
| Browser E2E testing | sonnet | general-purpose | qa-browser |
| Flutter/mobile testing | sonnet | general-purpose | qa-flutter |
| Performance/load testing | sonnet | general-purpose | qa-performance |
| Visual regression, a11y | sonnet | general-purpose | qa-visual |
For platforms like OpenCode where agent name determines model+tools, use named slim agents instead of ad-hoc routing:
| Agent | Model Tier | Role | Use For |
|---|---|---|---|
scout | fast | research | File search, quick lookup, simple Q&A |
coder | main | execution | Writing, editing, refactoring code |
planner | main | planning | Task breakdown, implementation plans |
researcher | heavy | research | Architecture design, deep codebase analysis |
reviewer | heavy | review | Code review, security audit, quality check |
In OpenCode, reference agents by name: the agent definition in pkg/agents/meta/ binds the correct model and skills automatically.
Task(model: "haiku", subagent_type: "Explore", prompt: "Find all usages of UserRepository interface in the codebase")
Task(model: "sonnet", subagent_type: "general-purpose", prompt: "Implement the CreateUser use case following Clean Architecture. Domain entity in internal/domain/entity/user.go, repository contract in internal/domain/contract/user.go, use case in internal/usecase/user/create.go")
Task(model: "opus", subagent_type: "general-purpose", prompt: "Design the authentication system architecture. Create design.md with component diagram, layer decisions, data flow, and database schema")
Task(model: "opus", subagent_type: "Explore", prompt: "Review the changes in internal/usecase/order/ for bugs, security issues, and adherence to Clean Architecture. Only report findings with confidence >= 80%")
Use haiku (fast) when:
Use sonnet (standard) when:
Use opus (heavy) when:
Is this a quick lookup or search?
YES → inline (or haiku Explore if large)
NO ↓
Does this need editing tools?
YES → sonnet general-purpose (or opus for complex)
NO → Explore agent type
Is this complex/ambiguous?
YES → opus
NO → sonnet (or haiku for trivial)
Can multiple tasks run in parallel?
YES → spawn separate Task calls
NO → work sequentially