#Local Ollama subagents failing with 8K context
1 messages · Page 1 of 1 (latest)
Local Ollama subagents failing with 8K context
First thing: please paste openclaw --version and ollama --version — version mismatches matter a lot here.
Likely fix: for stock Ollama, OLLAMA_NUM_CTX isn’t the documented env var; use OLLAMA_CONTEXT_LENGTH=32768 when starting ollama serve, or send num_ctx via the API/config. (github.com)
Also make sure OpenClaw’s config budget and Ollama’s runtime budget both say 32768:
models: {
providers: {
ollama: {
baseUrl: "http://127.0.0.1:11434", // no /v1
apiKey: "ollama-local",
api: "ollama",
contextWindow: 32768,
models: [{
id: "your-model",
Get up and running with Kimi-K2.5, GLM-5, MiniMax, DeepSeek, gpt-oss, Qwen, Gemma and other models. - ollama/ollama
name: "your-model",
contextWindow: 32768,
maxTokens: 8192,
params: { num_ctx: 32768, keep_alive: "15m" },
}],
},
},
}
OpenClaw docs specifically say contextWindow is OpenClaw’s prompt/compaction budget, while params.num_ctx is what gets sent to Ollama; keep them aligned. Also don’t use http://host:11434/v1 for Ollama in OpenClaw unless you intentionally want the less reliable OpenAI-compatible path. (docs.openclaw.ai)
If it only fails for subagents, check they’re actually using this model: subagents inherit the caller unless agents.defaults.subagents.model / per-agent subagent model is set. (docs.openclaw.ai)
Useful pasteables:
openclaw models list --provider ollama
openclaw models status
openclaw config get models.providers.ollama
openclaw config get agents.defaults.subagents.model
For “has anyone solved this on similar hardware?” also ask in #users-helping-users — that’s better for real-world Ollama/GPU experiences.
sorry for the late response. my OpenClaw version is 2026.4.22 and i am running Ollama at 0.18.3.
No worries — thanks, that helps.
You’re a few releases behind. I’d update OpenClaw first; there have been Ollama/subagent fixes since 2026.4.22.
For your exact version, the likely issue is: OpenClaw 2026.4.22 may still be seeing the model as 8K and sending that to Ollama, regardless of your OLLAMA_NUM_CTX / Modelfile attempt.
Do this:
openclaw update
openclaw doctor
openclaw gateway restart
Then verify what OpenClaw thinks the model context is:
openclaw models list --provider ollama
If it still shows 8K, define the Ollama model explicitly in ~/.openclaw/openclaw.json:
{
models: {
providers: {
ollama: {
baseUrl: "http://127.0.0.1:11434",
apiKey: "ollama-local",
api: "ollama",
contextWindow: 32768,
maxTokens: 8192,
models: [
{
id: "your-model-name",
name: "your-model-name",
input: ["text"],
contextWindow: 32768,
params: { num_ctx: 32768 }
}
]
}
}
},
agents: {
defaults: {
model: { primary: "ollama/your-model-name" }
}
}
}
Important bits:
- use
baseUrl: "http://127.0.0.1:11434"— no/v1 - use
api: "ollama"for native Ollama mode OLLAMA_NUM_CTXis not the one I’d rely on; Ollama’s documented env isOLLAMA_CONTEXT_LENGTH- after config changes:
openclaw gateway restartand start a fresh session/thread if possible
Docs: https://docs.openclaw.ai/providers/ollama
If it still fails, paste the exact error plus:
openclaw status --all
openclaw models list --provider ollama
Thanks.. this helps