GuidesHosting choices

OpenCode agents: Build, Plan, subagents and your own

OpenCode 2 agents: Build, Plan, the General and Explore subagents, Shift+Tab, calling a subagent, and writing your own with its own model and permissions.

November 23, 2026The Everpod team
The short answer

OpenCode has two kinds of agent. Primary agents hold your conversation: Build, the default, with every tool, and Plan, which is denied file edits so it can explore and plan. Press Shift+Tab to switch between them, or Ctrl+X then A to pick from a list. Subagents work in child sessions that a primary agent starts for a side task: General for multi-step work and Explore for searching code. Ask for one by name (“use the explore subagent to…”) or pick it from the @ menu, and it runs in the background with fresh context and reports back.

Your own agent is a Markdown file, .opencode/agents/<name>.md for one project or ~/.config/opencode/agents/<name>.md for all of them: the frontmatter sets description, mode, model (as provider/model) and permissions, and the body is its system prompt. The same fields work under agents in opencode.json. Write mode: subagent for a helper, because a new agent is a primary one unless you say otherwise. This is OpenCode 2.4.0 (November 23, 2026); version 1 switched agents with Tab and let a new agent run both ways.

The built-in agents: Build, Plan, General and Explore

Each agent starts from the same allow-everything policy and gets a few rules of its own, listed on OpenCode’s permissions page:

AgentKindWhat it may doModel
Build (build)
Primary, the defaultEvery tool, including files outside the project; asks before reading .env filesThe session’s
Plan (plan)
PrimaryEdits denied, except its own plan files in ~/.opencode/plan/; shell commands follow your rules, which allow them unless you add oneThe session’s
General (general)
SubagentEvery tool except asking you a question and starting another subagentThe parent session’s, unless you give it one
Explore (explore)
SubagentShell commands, reading files, glob and grep, web fetch and search, paths outside the project; everything else deniedThe parent session’s, unless you give it one
Compaction, Title, Summary
HiddenMaintenance: shrinking long sessions, naming them, summarising them; you can’t select themSet Title’s with agents.title.model

Three things in that table catch people. Plan’s block is on the file-editing tools, not the shell, so a shell command that writes a file still runs unless your rules stop it. Nothing in Plan’s permissions stops it starting General, which may edit: in OpenCode’s source it is only told, in a reminder added to the conversation, not to modify other files “or ask a subagent to do so.” And Explore’s prompt says its shell commands “MUST be read-only”, but its permissions allow any command. How to close Plan’s gaps is under changing the built-in agents, below.

Plan is told to write a plan file only when you ask for one, and puts it in ~/.opencode/plan/ in your home folder, not in the project. Ask it to make the change and it is told to answer that you need to switch agents.

Switching between agents

The agents page says “A session stores its selected model separately. Selecting a primary agent by ID does not change that model.” To run Plan on a stronger model than Build, check the model shown after switching and change it with Ctrl+X then M after switching, or pass --model beside --agent in a script. To start new sessions on an agent other than Build, set it as the default:

{
  "$schema": "https://opencode.ai/config.json",
  "default_agent": "plan"
}
Copied

The default has to be a visible agent that can run as a primary one; otherwise OpenCode falls back to Build. Changing it doesn’t move sessions that already exist.

Calling a subagent

The primary agent starts subagents with its subagent tool, and it decides when. Each subagent’s description is in the list of subagents the model sees, so the description is how it decides when to use yours; one without a description is listed as a subagent to call “only when explicitly requested.” To ask, name it:

Use the explore subagent to map the authentication flow and return the key files.
Copied

Explore’s own description asks for a thoroughness level, “quick”, “medium” or “very thorough”, so saying which you want in the request is worth a few words. Typing @ also lists the subagents beside your files and skills, and picking one puts @explore in your message. In 2.4.0 that mention reaches the model as part of what you wrote, and the primary agent still makes the call, under its permission rules; in version 1, an @-mention started the subagent directly.

What happens next, from the tools page and the agents page:

In the terminal interface, ↓ opens the subagent picker, Enter opens the selected child’s session and Ctrl+D interrupts it; from a child session, ↑ goes back to the parent.

A command can run as a subagent too. With subagent: true, the commands page says it runs “in a background child session”, and the parent “stays available and keeps its agent and model”:

.opencode/commands/audit.md

---
description: Audit changes
agent: general
subagent: true
---

Audit $ARGUMENTS for bugs and missing tests.
Copied

/audit src/billing then runs in a General child while you carry on. Left out, subagent uses a child only when the command’s agent has mode: subagent.

Writing your own agent

The file’s name is the agent’s ID, and a subfolder becomes part of it: .opencode/agents/team/reviewer.md is team/reviewer. Project agents are found in every .opencode/ folder from where you start OpenCode up to the project root. A read-only subagent on a smaller model:

.opencode/agents/migration-check.md

---
description: Reviews database migrations for locking, data loss and missing rollbacks. Use when a change adds or edits a migration.
mode: subagent
model: anthropic/claude-haiku-5-5
steps: 12
permissions:
  - action: "*"
    resource: "*"
    effect: deny
  - action: read
    resource: "*"
    effect: allow
  - action: grep
    resource: "*"
    effect: allow
  - action: glob
    resource: "*"
    effect: allow
---

Review the migrations you are pointed at. For each one, say which table it
touches, whether it takes a lock that blocks writes, whether it can lose data
and whether it can be rolled back. One short paragraph per migration, worst first.
Copied

Two defaults decide whether that works:

The same agent in opencode.json, where the prompt goes in system:

{
  "$schema": "https://opencode.ai/config.json",
  "agents": {
    "migration-check": {
      "description": "Reviews database migrations for locking, data loss and missing rollbacks.",
      "mode": "subagent",
      "model": "anthropic/claude-haiku-5-5",
      "system": "Review the migrations you are pointed at. Worst first.",
      "permissions": [
        { "action": "*", "resource": "*", "effect": "deny" },
        { "action": "read", "resource": "*", "effect": "allow" },
        { "action": "grep", "resource": "*", "effect": "allow" },
        { "action": "glob", "resource": "*", "effect": "allow" }
      ]
    }
  }
}
Copied

Every option, from the agents page:

FieldWhat it does
description
What the agent is for, and when to use it; the model choosing a subagent reads it
mode
primary (the default), subagent or all
model
provider/model, with an optional #variant such as #high; the IDs are the ones opencode models prints
system (the body, in a file)
The agent’s system prompt, in place of OpenCode’s own
permissions
Ordered allow, ask and deny rules, added after the global ones, the last match winning
steps
A cap on model steps; on the last one OpenCode removes the tools and asks for a summary in text, and your next message resets it
hidden
Keeps it out of lists, the @ menu and the subagent list; “This controls visibility, not security”
color
Its colour in the interface, as a six-digit hex value
disabled
Removes the agent, built-in ones included
request
Extra headers and body fields for its model requests, which 2.4.0 keeps but doesn’t send yet; set temperature and the like on a model variant

Which models you can name, and how variants work, is in OpenCode’s models guide. If a new agent doesn’t appear, opencode reload reloads the configuration without restarting the background server.

Changing the built-in agents

An entry with a built-in’s ID changes that agent. Single values such as model replace the built-in’s, and permission rules are added after its own, so they win where both match. This puts Explore on a smaller model and closes Plan’s gaps:

{
  "$schema": "https://opencode.ai/config.json",
  "agents": {
    "explore": { "model": "anthropic/claude-haiku-5-5" },
    "plan": {
      "permissions": [
        { "action": "edit", "resource": "*", "effect": "deny" },
        { "action": "edit", "resource": "~/.opencode/plan/*", "effect": "allow" },
        { "action": "shell", "resource": "*", "effect": "ask" },
        { "action": "shell", "resource": "git status *", "effect": "allow" },
        { "action": "shell", "resource": "git diff *", "effect": "allow" },
        { "action": "subagent", "resource": "*", "effect": "deny" },
        { "action": "subagent", "resource": "explore", "effect": "allow" }
      ]
    }
  }
}
Copied

The two edit rules look redundant but aren’t if your global rules allow edits: global rules come after the built-in ones, so a global edit allow lifts Plan’s block too, and restating it under agents.plan puts it back last. The shell rules make Plan ask before any command except the two Git reads. The subagent rules let it start Explore but not General; Explore can still run shell commands, because a subagent runs on its own rules, not its parent’s: it “uses its own permissions, not a subset of its parent’s permissions.” The rule format, where the config files live and which one wins are in OpenCode’s config guide, and the skill rules that decide which skills an agent may load are in the skills guide.

To remove a built-in, set "disabled": true on it, as in "plan": { "disabled": true }.

Seeing which agents loaded

opencode debug agents
grep -E "agent file skipped|ignored unsupported agent fields" ~/.local/share/opencode/log/opencode.log
Copied

Run from the project folder, opencode debug agents prints every agent loaded there as JSON, the hidden ones included, each with its mode, any model and system prompt set on it, and the full permission list it ended up with. That last part is the quickest way to see why Plan edited a file or a subagent couldn’t read one. A Markdown agent whose frontmatter OpenCode can’t read is left out, and the log says “agent file skipped”; a file mixing version 1 and version 2 fields loads, and the log names the fields it ignored.

Agents written for version 1

Version 2 still reads version 1 agent files and config, translating them as it loads, but the migration page says “Each file is read as one format”: one that uses any of permissions, request, system or disabled is read as version 2, and the version 1 fields in it are ignored. Convert a file all at once. What changed:

Version 1Version 2
agent (and mode) in opencode.json
agents
prompt
system, or the body in a Markdown file
permission map, tools
permissions, an ordered list
The task permission
subagent
model plus variant
provider/model#variant
maxSteps, disable
steps, disabled
temperature and top_p on an agent
No effect; set them on a model variant
mode left out means all
Left out means primary
Tab switches agents
Shift+Tab
@general starts the subagent, even where task permissions deny it
The mention goes to the primary agent, which calls it under its rules
opencode agent create, opencode agent list
No agent command: write the file, and check with opencode debug agents
subtask: true on a command
subagent: true (the old name still works)

The default mode is the change to look for after an upgrade: an agent file with no mode line, which version 1 would run as a subagent too, becomes a primary agent only and drops out of the subagent list. Files in the old agent/, mode/ and modes/ folders still load, those under mode/ and modes/ as primary agents. What else the upgrade changes, old sessions included, is in OpenCode 1 to 2.

OpenCode agents and Claude Code subagents

The subagent half is the same idea in both: a separate worker with its own context, prompt, tools and model, which hands back a result. The primary agents have no direct equivalent in Claude Code, where Shift+Tab cycles permission modes, plan mode among them, rather than agents, and claude --agent <name> runs a whole session as one subagent. Side by side, from Anthropic’s subagents page for Claude Code 2.1.330:

OpenCode 2.4.0Claude Code 2.1.330
Definitions
.opencode/agents/, ~/.config/opencode/agents/, or agents in opencode.json.claude/agents/, ~/.claude/agents/, or --agents JSON for one session
Identity
The file’s path, subfolder includedThe name field; subfolders don’t count
Limiting tools
permissions rules: allow, ask, denytools and disallowedTools lists
Model
provider/model from any provider; the parent’s if unsetAn alias such as haiku, a full model ID, or inherit
Background
AlwaysBy default, for custom subagents started from the main conversation
Nesting
None by defaultUp to three layers below the main conversation
An @-mention
Words in your message; the agent decides“tells Claude to run the subagent for one task”

OpenCode reads Claude Code’s skills folders but not .claude/agents/, and a Claude Code subagent file copied into .opencode/agents/ needs rewriting. Drop name, since the path is the ID; write the model as provider/model; turn the tools list into a deny for * followed by an allow for each tool, under OpenCode’s names for them (shell for Bash, edit for Edit and Write), as in the example above; and add mode: subagent, which Claude Code files don’t have. Copied unchanged, with its tools line in either form Claude Code accepts, the file is skipped in 2.4.0 (by OpenCode’s source) and the log says “agent file skipped”; once it has a permissions list, a leftover tools line is ignored with a warning instead. What Claude Code’s own subagents cost and when they help is in the Claude Code subagents guide, and the two agents as a whole are compared in OpenCode vs Claude Code.

Run OpenCode on an always-on developer pod.

A developer pod is a permanent cloud computer (VPS), set up and secured for you, with your pick of Claude Code, Codex, OpenCode, Pi, Hermes and OpenClaw installed. Run more agents at once than your laptop can hold, and keep them working when it’s closed. From $24 a month, built in about ten minutes.