ollama run igovet/gemma4:31b-opencode
Updated 3 days ago
3 days ago
cfa2d5488e48 · 444B ·
Modelfile & provider preset tuned for stable work inside OpenCode over Ollama Cloud.
When using Ollama Cloud models from OpenCode, several issues surface out of the box:
The settings below were arrived at empirically and raise the stability of Ollama Cloud + OpenCode to roughly 95%. The remaining edge cases look like Ollama Cloud throughput / model overload bugs, not configuration problems.
⚠️ These settings are experimental. They are not endorsed by Ollama or OpenCode — they are what happened to work best in our environment.
| Field | Value |
|---|---|
| Base model | gemma4:31b-cloud |
| Context window | 262144 |
| Output limit (in OpenCode) | 262144 (equals context) |
| Temperature | 0.7 |
| Top-p / Top-k / Min-p | 0.95 / 50 / 0.05 |
| Repeat penalty | 1.1 (last 2048 tokens) |
| Variants | high / medium / low / none |
FROM gemma4:31b-cloud
PARAMETER num_ctx 262144
PARAMETER num_predict 16384
PARAMETER temperature 0.7
PARAMETER top_p 0.95
PARAMETER top_k 50
PARAMETER min_p 0.05
PARAMETER repeat_penalty 1.1
PARAMETER repeat_last_n 2048
{
"$schema": "https://opencode.ai/config.json",
"provider": {
"ollama": {
"npm": "@ai-sdk/openai-compatible",
"name": "Ollama",
"options": {
"baseURL": "http://localhost:11434/v1",
"timeout": 1200000,
"headerTimeout": 1200000
},
"models": {
"igovet/gemma4:31b-opencode": {
"_launch": false,
"name": "Gemma4 31b OpenCode",
"limit": {
"context": 262144,
"output": 262144
},
"variants": {
"high": { "reasoningEffort": "high" },
"medium": { "reasoningEffort": "medium" },
"low": { "reasoningEffort": "low" },
"none": { "reasoningEffort": "none" }
}
}
}
}
}
}
output is set equal to contextOllama does not honor a separate output (max output tokens) reliably through the OpenAI-compatible surface that @ai-sdk/openai-compatible speaks to. If you set output near 16384 you will see the stream cut off mid-response with no error.
The workaround used here is to make output formally equal to context. The model still decides when to stop on its own; we just stop clipping it on the client side.
timeout and headerTimeout are bumped to 20 minutes (1200000 ms). Cloud models occasionally queue for several minutes during peak load, and the default AI SDK timeouts will fire long before that.
Gemma models are sensitive to top-k/min-p defaults. The values here (top_k 50, min_p 0.05) match the recommended setup from the Gemma 4 release notes and noticeably reduce degenerate repetition on long generations.
| OpenCode variant | Use it for |
|---|---|
high |
Multi-file refactors, architecture-level reasoning, debugging subtle cross-module issues. Best when the orchestrator is delegating complex work. |
medium |
Default for sub-agents (backend-developer, full-stack-developer) on a well-scoped task. |
low |
Quick reads — code-reviewer, security-auditor on small diffs, explore agent. |
none |
Inline completions, classification, or short replies where reasoning adds latency without value. |