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
Model ID to use for the coder agent. See provider configuration for available options.Recommended models:
claude-4-sonnet- Best overall coding performanceclaude-3.7-sonnet- Excellent coding with extended thinkinggpt-4.1- Strong reasoning and large contextcopilot.gpt-4o- Free with GitHub Copilot subscription
Maximum tokens for agent responses. Higher values allow longer responses but increase cost.Recommendations:
5000-8000- Standard coding tasks10000-20000- Complex multi-file changes30000-50000- Large-scale refactoring (reasoning models)
Reasoning effort level for models that support extended thinking (OpenAI o-series, Anthropic extended thinking, etc.).Options:
low- Faster responses, less deep analysismedium- Balanced performance (recommended)high- Deepest analysis, slower responses
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)
View default system prompt excerpt
View default system prompt excerpt
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
Model ID to use for the task agent.Recommended models:
gpt-4.1-mini- Fast and cost-effectiveclaude-3.5-haiku- Fast Claude modelgemini-2.5-flash- Fast with large contextcopilot.gpt-4o-mini- Free with GitHub Copilot
Maximum tokens for task agent responses.
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
Model ID to use for the title agent.Recommended models:
gpt-4.1-mini- Fast and cost-effectiveclaude-3.5-haiku- Fast Claude modelgemini-2.5-flash- Fast Gemini modelcopilot.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