@ mention.
Types
There are two types of agents in OpenCode: primary agents and subagents.Primary agents
Primary agents are the main assistants you interact with directly. You can cycle through them using the Tab key, or your configuredswitch_agent keybind. These agents handle your main conversation. Tool access is configured via permissions — for example, Build has all tools enabled while Plan is restricted.
OpenCode comes with two built-in primary agents: Build and Plan.
Subagents
Subagents are specialized assistants that primary agents can invoke for specific tasks. You can also manually invoke them by @ mentioning them in your messages. OpenCode comes with two built-in subagents: General and Explore.Built-in Agents
OpenCode comes with two built-in primary agents and two built-in subagents.Build
Mode: Primary
- Full tool access (read, write, edit, bash, etc.)
- Ideal for active development and implementation
- Can modify files and execute commands without restrictions
- Best for building features, fixing bugs, and refactoring code
Plan
Mode: Primary
ask:
- File edits: All writes, patches, and edits
- Bash commands: All bash/shell commands
- Code analysis and review
- Architecture planning
- Proposing refactoring strategies
- Exploring implementation options
General
Mode: Subagent
- Running multiple units of work in parallel
- Complex research tasks requiring file exploration
- Multi-step implementation tasks
- Tasks requiring both reading and writing
Explore
Mode: Subagent
- Quickly find files by patterns
- Search code for keywords and patterns
- Answer questions about the codebase structure
- Code exploration without risk of modification
- Read-only access (read, grep, glob, ls)
- Fast and efficient for code discovery
- Safe for exploration without side effects
Usage
Switching Primary Agents
Use the Tab key to cycle through primary agents during a session. You can also use your configuredswitch_agent keybind.
Invoking Subagents
Subagents can be invoked in two ways:- Automatically by primary agents for specialized tasks based on their descriptions
- Manually by @ mentioning a subagent in your message:
Navigation Between Sessions
When subagents create their own child sessions, you can navigate between the parent session and all child sessions:- Leader+Right (or your configured
session_child_cyclekeybind) to cycle forward through parent → child1 → child2 → … → parent - Leader+Left (or your configured
session_child_cycle_reversekeybind) to cycle backward
Configure
You can customize the built-in agents or create your own through configuration. Agents can be configured in two ways:JSON Configuration
Configure agents in youropencode.json config file:
opencode.json
Markdown Configuration
You can also define agents using markdown files. Place them in:- Global:
~/.config/opencode/agents/ - Per-project:
.opencode/agents/
~/.config/opencode/agents/review.md
review.md creates a review agent.
Configuration Options
Description
Provide a brief description of what the agent does and when to use it.opencode.json
Mode
Control the agent’s mode. Themode option determines how the agent can be used.
opencode.json
mode option can be set to primary, subagent, or all. If no mode is specified, it defaults to all.
Model
Override the model for this agent. Useful for using different models optimized for different tasks.opencode.json
provider/model-id. For example, if you’re using OpenCode Zen, you would use opencode/gpt-5.1-codex for GPT 5.1 Codex.
Prompt
Specify a custom system prompt file for this agent.opencode.json
Temperature
Control the randomness and creativity of the AI’s responses.opencode.json
- 0.0-0.2: Very focused and deterministic responses, ideal for code analysis and planning
- 0.3-0.5: Balanced responses with some creativity, good for general development tasks
- 0.6-1.0: More creative and varied responses, useful for brainstorming and exploration
Tools
Control which tools are available to this agent.opencode.json
The agent-specific config overrides the global config.
opencode.json
Permissions
Configure permissions to manage what actions an agent can take. Permissions foredit, bash, and webfetch tools can be configured to:
"ask"— Prompt for approval before running the tool"allow"— Allow all operations without approval"deny"— Disable the tool
opencode.json
opencode.json
Max Steps
Control the maximum number of agentic iterations an agent can perform before being forced to respond with text only.opencode.json
Task Permissions
Control which subagents an agent can invoke via the Task tool. Uses glob patterns for flexible matching.opencode.json
deny, the subagent is removed from the Task tool description entirely, so the model won’t attempt to invoke it.
Users can always invoke any subagent directly via the
@ autocomplete menu, even if the agent’s task permissions would deny it.Hidden
Hide a subagent from the@ autocomplete menu with hidden: true. Useful for internal subagents that should only be invoked programmatically by other agents via the Task tool.
opencode.json
Only applies to
mode: subagent agents.Other Options
Color
Color
Customize the agent’s visual appearance in the UI.Use a valid hex color (e.g.,
#FF5733) or theme color: primary, secondary, accent, success, warning, error, info.opencode.json
Top P
Top P
Control response diversity with the Values range from 0.0 to 1.0. Lower values are more focused, higher values more diverse.
top_p option. Alternative to temperature for controlling randomness.opencode.json
Disable
Disable
Set to
true to disable the agent.opencode.json
Additional Options
Additional Options
Any other options you specify in your agent configuration will be passed through directly to the provider as model options. This allows you to use provider-specific features.For example, with OpenAI’s reasoning models, you can control the reasoning effort:
opencode.json
Creating Agents
You can create new agents using the CLI command:- Ask where to save the agent (global or project-specific)
- Request a description of what the agent should do
- Generate an appropriate system prompt and identifier
- Let you select which tools the agent can access
- Create a markdown file with the agent configuration
Use Cases
Here are some common use cases for different agents:- Build agent: Full development work with all tools enabled
- Plan agent: Analysis and planning without making changes
- Review agent: Code review with read-only access plus documentation tools
- Debug agent: Focused on investigation with bash and read tools enabled
- Docs agent: Documentation writing with file operations but no system commands
Examples
Documentation Agent
~/.config/opencode/agents/docs-writer.md
Security Auditor
~/.config/opencode/agents/security-auditor.md