Built-in agents
| Agent | Mode | Purpose |
|---|---|---|
Build (build) | primary | Default coding agent. Tools are allowed by default, sensitive environment-file reads ask for approval, and access outside the workspace asks for approval. |
Plan (plan) | primary | Planning agent. File edits are denied except for OpenCode plan files. Shell commands are not generally denied. |
General (general) | subagent | General-purpose research and multi-step work. It has broad tool access but cannot launch more subagents. |
Explore (explore) | subagent | Read-only code and web exploration using read, glob, grep, webfetch, and websearch. |
compaction, title, and summary system agents.
They run internal maintenance tasks and are not selectable. There is no built-in
scout agent in V2.
You can override a built-in agent with an entry of the same ID. Set
disabled: true to remove one.
Default agent
Set the primary agent used when a session has not selected one:opencode.jsonc
mode: "subagent", and must not
be hidden. If it is unavailable, OpenCode falls back to build, then to the
first visible agent that can run as a primary agent. This selection does not
rewrite the agent already stored on an existing session.
Modes
An agent’smode controls where it can run:
| Mode | Behavior |
|---|---|
primary | Can be selected as the main agent for a session. It cannot be launched as a subagent. |
subagent | Can run in a child session through the subagent tool, but cannot be selected as the main agent. |
all | Can be used either way. This is the default for a custom agent when mode is omitted. |
all agents, or use /agents to choose one.
Subagents run in child sessions with fresh context. A primary agent can invoke
one with the subagent tool, either in the foreground or in the background.
You can also @ mention a visible subagent to ask the current agent to delegate
work to it:
subagent permission controls which agents it may launch.
The child currently uses its own configured permissions, not a restricted copy
of the parent’s permissions.
Configure agents
Markdown files
The recommended file locations are:.opencode directories from the current directory
up to the project root. The path below agents/ becomes the agent ID, so
.opencode/agents/team/reviewer.md defines team/reviewer.
Frontmatter uses the same fields as an entry under agents. The Markdown body
becomes system:
.opencode/agents/reviewer.md
JSON or JSONC
Use theagents field in any OpenCode configuration file:
opencode.jsonc
permissions are applied to every agent before its agent-specific rules,
so a later agent rule can refine a global rule.
Options
description
Explains the agent’s purpose. It is optional, but strongly recommended for
subagents because OpenCode includes it in the subagent catalog shown to the
model.
mode
Accepts primary, subagent, or all. The default is all.
model
Selects a model using provider/model with an optional #variant:
system
Sets the agent’s system prompt. A non-empty value replaces OpenCode’s
provider-specific base prompt for that agent. Project instructions, skills,
references, and other instruction sources are still added separately.
For a Markdown agent, use the document body instead of a system frontmatter
field.
permissions
Permissions are an ordered array of rules:
| Field | Meaning |
|---|---|
action | Tool or permission action, with * wildcards supported. |
resource | The path, command, agent ID, or other resource matched by the action. Wildcards are supported. |
effect | allow, ask, or deny. |
shell for
shell commands, edit for all edit/write/patch tools, and subagent for child
agents. Other tools generally use their tool name, such as read, glob,
grep, webfetch, websearch, and skill.
~ and $HOME are expanded in filesystem resources for read, edit, and
external_directory. Shell resources are raw command text and are not
expanded.
steps
Sets a positive maximum number of model steps. On the final allowed step,
OpenCode removes tools and asks the model to summarize its work in text. New
user input resets the allowance.
hidden
When true, removes the agent from normal selectors, @ autocomplete, and the
subagent catalog advertised to models. It is a visibility setting, not a
security boundary.
color
Sets the agent’s UI color. Use a six-digit hex color such as #ff6b6b, or one
of primary, secondary, accent, success, warning, error, or info.
disabled
When true, removes the agent definition at that point in configuration
loading. This works for built-in and custom agents.
request
The V2 schema accepts per-agent request headers and JSON body overlays: