-
Notifications
You must be signed in to change notification settings - Fork 4.8k
Description
Description
When using the OpenCode Server HTTP API to send a message with only the agent parameter (without explicitly passing model), the server does not use the agent's configured default model from opencode.json. Instead, it falls back to the global default model.
Configuration in ~/.config/opencode/opencode.json:
{
"model": "anthropic/claude-opus-4-5",
"agent": {
"build": {
"model": "anthropic/claude-opus-4-5"
},
"plan": {
"model": "openai/gpt-5.2",
"reasoningEffort": "xhigh"
}
}
}API Request:
curl -X POST "http://localhost:4096/session/{session_id}/message" \
-H "x-opencode-directory: /path/to/project" \
-H "Content-Type: application/json" \
-d '{"agent": "plan", "parts": [{"type": "text", "text": "Hello"}]}'Expected behavior:
The server should use openai/gpt-5.2 (the model configured for the plan agent).
Actual behavior:
The server uses google/gemini-3-pro-preview (or another fallback model), ignoring the agent's configured model.
Evidence from API response:
{
"info": {
"modelID": "gemini-3-pro-preview",
"providerID": "google",
"agent": "plan"
}
}Additional context:
- The
/agentAPI endpoint returns native agents (build,plan) without their configuredmodelfield, even though the model is specified inopencode.json - The
/configAPI only returns custom agents (likecode-reviewer) with their model configuration, not native agents - According to the documentation, agent-specific models should override the global default
This issue affects users who want to use different models for different agents via the Server API, which is a common use case for building integrations and plugins.
Plugins
opencode-antigravity-auth@1.2.7
OpenCode version
1.1.3
Steps to reproduce
-
Configure agent-specific models in
~/.config/opencode/opencode.json:{ "agent": { "plan": { "model": "openai/gpt-5.2" } } } -
Start the OpenCode server:
opencode serve -
Create a session via API:
curl -X POST "http://localhost:4096/session" \ -H "x-opencode-directory: /path/to/project" \ -H "Content-Type: application/json" \ -d '{}'
-
Send a message with only the
agentparameter:curl -X POST "http://localhost:4096/session/{session_id}/message" \ -H "x-opencode-directory: /path/to/project" \ -H "Content-Type: application/json" \ -d '{"agent": "plan", "parts": [{"type": "text", "text": "What model are you?"}]}'
-
Observe that the response uses a different model than configured for the
planagent
Screenshot and/or share link
No response
Operating System
macOS 15.5
Terminal
No response