Skip to main content
OpenCode uses specialized AI agents for different tasks. Each agent can be configured with a different model, token limit, and reasoning parameters to optimize for its specific use case.

Agent types

OpenCode has three built-in agents:

Coder

Main interactive agent for coding tasks, file editing, and complex operations

Task

Background agent for file search, grep operations, and code analysis

Title

Specialized agent for generating concise session titles

Coder agent

The coder agent is the primary agent you interact with during coding sessions. It handles all user interactions, code editing, file operations, and complex reasoning tasks.

Configuration

Properties

string
required
Model ID to use for the coder agent. See provider configuration for available options.Recommended models:
  • claude-4-sonnet - Best overall coding performance
  • claude-3.7-sonnet - Excellent coding with extended thinking
  • gpt-4.1 - Strong reasoning and large context
  • copilot.gpt-4o - Free with GitHub Copilot subscription
integer
default:"5000"
Maximum tokens for agent responses. Higher values allow longer responses but increase cost.Recommendations:
  • 5000-8000 - Standard coding tasks
  • 10000-20000 - Complex multi-file changes
  • 30000-50000 - Large-scale refactoring (reasoning models)
string
Reasoning effort level for models that support extended thinking (OpenAI o-series, Anthropic extended thinking, etc.).Options:
  • low - Faster responses, less deep analysis
  • medium - Balanced performance (recommended)
  • high - Deepest analysis, slower responses
Only applicable to models with reasoning capabilities. See provider configuration for which models support reasoning.

Behavior

The coder agent is designed to:
  • Be concise and direct (max 4 lines of text unless user requests detail)
  • Use tools proactively to gather information before answering
  • Follow existing code conventions and patterns
  • Run linting and typechecking after making changes
  • Avoid adding unnecessary comments unless requested
  • Never commit changes unless explicitly asked

System prompt

The coder agent uses a comprehensive system prompt that includes:
  • Instructions for tool usage and proactive behavior
  • Code style guidelines (minimal comments, follow conventions)
  • Task completion workflow (search → implement → verify)
  • Environment information (working directory, platform, git status)
  • LSP integration details (when configured)

Task agent

The task agent handles background operations and specialized tasks. It’s optimized for quick, focused operations like file search, grep, and code analysis.

Configuration

Properties

string
required
Model ID to use for the task agent.Recommended models:
  • gpt-4.1-mini - Fast and cost-effective
  • claude-3.5-haiku - Fast Claude model
  • gemini-2.5-flash - Fast with large context
  • copilot.gpt-4o-mini - Free with GitHub Copilot
integer
default:"5000"
Maximum tokens for task agent responses.
string
Reasoning effort level (same options as coder agent).

Behavior

The task agent is designed to:
  • Provide concise, direct answers without elaboration
  • Use absolute file paths (never relative paths)
  • Share relevant file names and code snippets
  • Focus on the specific query without tangential information

Use cases

  • File search: Finding files by name or pattern
  • Code search: Searching for specific code patterns with grep
  • Analysis: Analyzing code structure and dependencies
  • Quick queries: Answering specific questions about the codebase

System prompt

The task agent uses a simplified system prompt:

Title agent

The title agent generates concise session titles based on the first user message. This helps organize and identify sessions in the session history.

Configuration

Properties

string
required
Model ID to use for the title agent.Recommended models:
  • gpt-4.1-mini - Fast and cost-effective
  • claude-3.5-haiku - Fast Claude model
  • gemini-2.5-flash - Fast Gemini model
  • copilot.gpt-4o-mini - Free with GitHub Copilot
The maxTokens parameter is automatically set to 80 for the title agent and cannot be configured. The reasoningEffort parameter is not used.

Behavior

The title agent is designed to:
  • Generate titles under 50 characters
  • Create one-line summaries without quotes or colons
  • Capture the essence of the user’s query
  • Return only the title text (no additional commentary)

System prompt

Model selection guide

Choose models based on your priorities:

For performance

For cost

For speed

Fast inference

For context window

Large context

Validation

OpenCode automatically validates your agent configuration:
  • Model existence: Checks if the specified model is supported
  • Provider availability: Verifies the provider is configured with valid credentials
  • Token limits: Ensures maxTokens doesn’t exceed half the context window
  • Reasoning support: Validates reasoningEffort is only used with compatible models
  • Fallback: Automatically uses default models if configuration is invalid
If a configured model is unavailable, OpenCode will warn you and fall back to a default model based on your available providers. Check logs if you see unexpected model usage.

Advanced configuration

Using different providers for different agents

Mix providers to optimize for cost and performance:

High-performance reasoning setup

For maximum reasoning capability:

Budget-conscious configuration

Minimize costs while maintaining quality:

Testing your configuration

After modifying your agent configuration, test it:
OpenCode displays active models and token usage in the interface.

Environment-specific configuration

Use local configuration files to customize agents per project:
Local configuration overrides global settings for that directory.