Chapter 5: Agents, Subagents, and Planning
April 13, 2026 ยท View on GitHub
Welcome to Chapter 5: Agents, Subagents, and Planning. In this part of OpenCode Tutorial: Open-Source Terminal Coding Agent at Scale, you will build an intuitive mental model first, then move into concrete implementation details and practical production tradeoffs.
OpenCode includes distinct agent behaviors that should be chosen intentionally by task type.
Built-in Agent Modes
| Agent | Strength |
|---|---|
| build | full-access implementation and execution |
| plan | read-only analysis and exploration |
| general (subagent) | complex search and multi-step discovery |
Mode Selection Heuristic
- use
planfor unfamiliar codebases and risk analysis - switch to
buildonly when plan quality is acceptable - use
generalfor deep discovery and context prep
Review Pattern
- ask
planto map scope and risks - confirm constraints and test strategy
- hand off to
buildfor implementation - validate and finalize with tests and diff review
Source References
Summary
You can now use OpenCode modes as a controlled workflow, not just a toggle.
Next: Chapter 6: Client/Server and Remote Workflows
How These Components Connect
flowchart LR
A[Task Input] --> B{Agent Mode}
B -->|plan| C[Planning Agent]
B -->|build| D[Build Agent]
C --> E[Step-by-step Plan]
D --> F[Subagent Dispatch]
F --> G[File Tools]
F --> H[Shell Tools]
E --> I[Human Review]