Description
opencode automatically adds sampling parameters to chat requests for some model names/ids, even if not configured to do so.
I think that opencode should not be doing this, or there should be a way to opt-out, or it should be changed to an opt-in setting.
The defaults are defined in:
packages/opencode/src/provider/transform.ts
Specifically:
ProviderTransform.temperature()
ProviderTransform.topP()
ProviderTransform.topK()
They are applied in:
packages/opencode/src/session/llm/request.ts
The checks use substring matches against the model name/id (lowercased)
Current defaults include:
- Model IDs containing
north-mini-code: temperature 1.0
- Model IDs containing
qwen: temperature 0.55, top_p 1.0
- Matching Gemini 2.5, Gemini 3 Flash/Pro, Gemini 3.1, and Gemini 3.5 Flash models: temperature
1.0, top_p 0.95, top_k 64
- Model IDs containing
glm-4.6 or glm-4.7: temperature 1.0
- Model IDs containing
minimax-m2: temperature 1.0, top_p 0.95, top_k 20 or 40
- Model IDs containing
kimi-k2: temperature 0.6 or 1.0
- Kimi K2.5 variants: top_p
0.95
- DeepSeek V4 Flash models: top_p
0.95 in specific cases
I discovered this when running Qwen 3.8 27B locally in llama.cpp and pointing my opencode config at it. The recommended setting for Qwen 3.8 is top-p 0.95, which is being overridden by these automatically generated sampling parameters. (I specify temperature and top-p settings in llama.cpp for the model)
This means i need to also set top_p in opencode config to work around this hardcoded value.
Plugins
none
OpenCode version
1.18.18
Steps to reproduce
-
Configure a single local OpenAI-compatible Qwen model:
{
"$schema": "https://opencode.ai/config.json",
"provider": {
"llama": {
"npm": "@ai-sdk/openai-compatible",
"options": {
"baseURL": "http://localhost:8001/v1"
},
"models": {
"Qwen-3.8-27B": {
"name": "Qwen-3.8-27B"
}
}
}
}
}
-
Select Qwen-3.8-27B.
-
Send a prompt to the model.
-
Inspect the request sent to the server. It contains top_p 1.0, based on the model key.
Screenshot and/or share link
No response
Operating System
No response
Terminal
No response
Description
opencode automatically adds sampling parameters to chat requests for some model names/ids, even if not configured to do so.
I think that opencode should not be doing this, or there should be a way to opt-out, or it should be changed to an opt-in setting.
The defaults are defined in:
Specifically:
ProviderTransform.temperature()ProviderTransform.topP()ProviderTransform.topK()They are applied in:
The checks use substring matches against the model name/id (lowercased)
Current defaults include:
north-mini-code: temperature1.0qwen: temperature0.55, top_p1.01.0, top_p0.95, top_k64glm-4.6orglm-4.7: temperature1.0minimax-m2: temperature1.0, top_p0.95, top_k20or40kimi-k2: temperature0.6or1.00.950.95in specific casesI discovered this when running Qwen 3.8 27B locally in llama.cpp and pointing my opencode config at it. The recommended setting for Qwen 3.8 is top-p 0.95, which is being overridden by these automatically generated sampling parameters. (I specify temperature and top-p settings in llama.cpp for the model)
This means i need to also set top_p in opencode config to work around this hardcoded value.
Plugins
none
OpenCode version
1.18.18
Steps to reproduce
Configure a single local OpenAI-compatible Qwen model:
{ "$schema": "https://opencode.ai/config.json", "provider": { "llama": { "npm": "@ai-sdk/openai-compatible", "options": { "baseURL": "http://localhost:8001/v1" }, "models": { "Qwen-3.8-27B": { "name": "Qwen-3.8-27B" } } } } }Select
Qwen-3.8-27B.Send a prompt to the model.
Inspect the request sent to the server. It contains
top_p1.0, based on the model key.Screenshot and/or share link
No response
Operating System
No response
Terminal
No response