Repository navigation
Closed
Labels
P2Normal backlog priority with limited blast radius.Normal backlog priority with limited blast radius.bugSomething isn't workingSomething isn't workingbug:behaviorIncorrect behavior without a crashIncorrect behavior without a crashimpact:session-stateSession, memory, transcript, context, or agent state can drift or corrupt.Session, memory, transcript, context, or agent state can drift or corrupt.
Description
Bug type
Behavior bug (incorrect output/state without crash)
Beta release blocker
No
Summary
OpenClaw appears to allow an oversized context to be sent to an Ollama cloud model before enforcing/handling context overflow. In my case, a single ollama/nemotron-3-ultra:cloud turn was recorded as using more than 14 million input tokens, immediately consuming the Ollama session usage quota. The next turn then failed with OpenClaw’s own context overflow message.
This may be partly an Ollama/Nemotron usage-reporting bug, which I have reported to Ollama separately. However, OpenClaw should probably prevent a prompt far beyond the configured model context window from being sent in the first place.
Steps to reproduce
- OpenClaw version:
2026.6.1 - Runtime: Gateway / WebChat
- OS: Windows
- Provider:
ollama - Model:
ollama/nemotron-3-ultra:cloud - Ollama base URL:
https://ollama.com - Configured model context window:
128000
- I added
ollama/nemotron-3-ultra:cloudto the OpenClaw model dropdown and restarted the gateway. - I selected the model and sent a simple greeting:
오 안녕 네모트론 자비스. 네모트론은 처음써보네. agent 성능이 제일 높더라고? - The model returned a normal short reply.
- OpenClaw recorded the turn with extremely large usage:
{
"provider": "ollama",
"model": "nemotron-3-ultra:cloud",
"usage": {
"input": 14255600,
"output": 20895,
"total": 14276495
}
}
Context is too large and auto-compaction could not recover this turn. Try again, use /compact, or use /new to start a fresh session.
429 {"error":"you (<redacted>) have reached your session usage limit, upgrade for higher limits: https://ollama.com/upgrade or add extra usage: https://ollama.com/settings (ref: daa22fad-4d66-4a69-a7c8-dcad944a4d76)"}
### Expected behavior
OpenClaw should not send a prompt that is far beyond the model’s configured context window.
Before dispatching the request, OpenClaw should either:
run compaction,
reject the turn locally,
truncate according to the configured context policy,
or surface a clear preflight error.
The important part is that the cloud provider should not receive a huge prompt first and only then have OpenClaw report context overflow on the next turn.
### Actual behavior
A single simple user message was successfully sent to the Ollama cloud model, but the recorded usage shows 14,255,600 input tokens. Only the following turn produced OpenClaw’s local context overflow error.
### OpenClaw version
2026.6.1
### Operating system
windows 11
### Install method
npm global
### Model
ollama/nemotron-3-ultra:cloud
### Provider / routing chain
openclaw -> ollama -> cloud api
### Additional provider/model setup details
_No response_
### Logs, screenshots, and evidence
```shell
Impact and severity
No response
Additional information
No response
Reacted by clawsweeper
Metadata
Metadata
Assignees
Labels
P2Normal backlog priority with limited blast radius.Normal backlog priority with limited blast radius.bugSomething isn't workingSomething isn't workingbug:behaviorIncorrect behavior without a crashIncorrect behavior without a crashimpact:session-stateSession, memory, transcript, context, or agent state can drift or corrupt.Session, memory, transcript, context, or agent state can drift or corrupt.
Type
Fields
Priority
None yet
Activity
clawsweeper commentedon Jun 4, 2026
Thanks for the context here. I did a careful shell check against current
main, and this is already implemented.Current main and the latest release now cover the reported oversized-context path: the embedded runner resolves the effective context budget and runs a pre-provider prompt-pressure precheck that skips model submission when recovery is needed.
So I’m closing this as already implemented rather than keeping a duplicate issue open.
Review details
Best possible solution:
Keep the shipped generic runner-side precheck and ask for a fresh report only if Ollama Cloud still shows oversized dispatch after
v2026.6.6or a current-main build.Do we have a high-confidence way to reproduce the issue?
Yes from source for the oversized-context path: current main computes a context budget and runs a pre-provider LLM-boundary precheck before prompt submission. I did not run a live Ollama Cloud repro.
Is this the best way to solve the issue?
Yes. The shipped fix is the maintainable generic boundary because it prevents provider dispatch before transport instead of adding Ollama-specific policy.
Security review:
Security review: Not applicable to an ordinary non-PR issue review with no security-sensitive report.
AGENTS.md: found and applied where relevant.
What I checked:
src/agents/embedded-agent-runner/run/setup.ts:147, 8682d0701b27)ctxInfo.tokensascontextTokenBudgetintorunEmbeddedAttemptWithBackend. (src/agents/embedded-agent-runner/run.ts:1775, 8682d0701b27)promptActiveSession, the attempt runner estimates LLM-boundary token pressure and callsshouldPreemptivelyCompactBeforePromptwith the resolved context budget. (src/agents/embedded-agent-runner/run/attempt.ts:4448, 8682d0701b27)promptErrorSource = "precheck"andskipPromptSubmission = true; the provider call only happens inside the laterif (!skipPromptSubmission)block. (src/agents/embedded-agent-runner/run/attempt.ts:4554, 8682d0701b27)shouldPreemptivelyCompactBeforePromptcompares estimated prompt pressure withcontextTokenBudget, computes overflow, and choosesfits,compact_only,truncate_tool_results_only, orcompact_then_truncate. (src/agents/embedded-agent-runner/run/preemptive-compaction.ts:263, 8682d0701b27)src/agents/embedded-agent-runner/run/preemptive-compaction.test.ts:230, 8682d0701b27)Likely related people:
src/agents/embedded-agent-runner/run/attempt.ts,src/agents/embedded-agent-runner/run/preemptive-compaction.ts)v2026.6.6proof commit that contains the current precheck source is authored by Vincent Koc, and the current blame commit also lists Vincent Koc as co-author. (role: release/proof commit author; confidence: medium; commits: 8c802aa68351, 44e6caff5401; files:src/agents/embedded-agent-runner/run/attempt.ts,src/agents/embedded-agent-runner/run/preemptive-compaction.ts)src/agents/embedded-agent-runner/run/attempt.ts,src/agents/embedded-agent-runner/run/preemptive-compaction.ts)src/agents/embedded-agent-runner/run/attempt.ts,src/agents/embedded-agent-runner/run/preemptive-compaction.ts)src/agents/embedded-agent-runner/run/preemptive-compaction.ts,src/agents/agent-settings.ts)Codex review notes: model internal, reasoning high; reviewed against 8682d0701b27; fix evidence: release v2026.6.6, commit 8c802aa68351.