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
/agent API endpoint returns native agents (build, plan) without their configured model field, even though the model is specified in opencode.json
- The
/config API only returns custom agents (like code-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 agent parameter:
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 plan agent
Screenshot and/or share link
No response
Operating System
macOS 15.5
Terminal
No response
Description
When using the OpenCode Server HTTP API to send a message with only the
agentparameter (without explicitly passingmodel), the server does not use the agent's configured default model fromopencode.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:
Expected behavior:
The server should use
openai/gpt-5.2(the model configured for theplanagent).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:
/agentAPI endpoint returns native agents (build,plan) without their configuredmodelfield, even though the model is specified inopencode.json/configAPI only returns custom agents (likecode-reviewer) with their model configuration, not native agentsThis 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 serveCreate a session via API:
Send a message with only the
agentparameter:Observe that the response uses a different model than configured for the
planagentScreenshot and/or share link
No response
Operating System
macOS 15.5
Terminal
No response