文档
English Docs
Agents

Agents

Agents are specialized AI assistants configured for specific tasks and workflows. They enable focused tools with custom prompts, models, and tool access.

Agent Types

Primary Agents

Main assistants for direct interaction. Cycle through them via Tab key.

  • Build: Default agent with all tools enabled
  • Plan: Restricted agent for planning and analysis

Subagents

Specialized assistants invoked by primary agents or via @ mentions.

  • General: General-purpose for multi-step tasks
  • Explore: Fast codebase exploration

Configuration Methods

JSON Configuration

{
  "agent": {
    "review": {
      "mode": "subagent",
      "model": "anthropic/claude-sonnet-4",
      "tools": {
        "write": false,
        "edit": false
      }
    }
  }
}

Markdown Configuration

Place in ~/.config/opencode/agent/ or .opencode/agent/:

---
description: Reviews code for quality
mode: subagent
temperature: 0.1
tools:
  write: false
  edit: false
---
You are in code review mode. Focus on quality and security.

Configuration Options

OptionPurpose
descriptionBrief description (required)
temperatureResponse randomness (0.0-1.0)
maxStepsLimit agentic iterations
modelOverride global model
toolsEnable/disable tools
permissionTool access control
modeprimary, subagent, or all

Creating Agents

opencode agent create

Common Use Cases

  • Build agent: Full development
  • Plan agent: Analysis without changes
  • Review agent: Code review (read-only)
  • Debug agent: Investigation
  • Docs agent: Documentation writing