Skip to content

[Bug]: Ollama cloud model received a 14M-token prompt before OpenClaw detected context overflow #90372

Closed

Description

@JsuHod

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
  1. I added ollama/nemotron-3-ultra:cloud to the OpenClaw model dropdown and restarted the gateway.
  2. I selected the model and sent a simple greeting:
    오 안녕 네모트론 자비스. 네모트론은 처음써보네. agent 성능이 제일 높더라고?
  3. The model returned a normal short reply.
  4. 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

Activity

  1. clawsweeper commented on Jun 4, 2026

    @clawsweeper
    Contributor

    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.6 or 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:

    Likely related people:

    • mushuiyu_xydt: Current-main blame for the pre-prompt context precheck and routing helper points to their commit. (role: recent area contributor; confidence: medium; commits: 44e6caff5401; files: src/agents/embedded-agent-runner/run/attempt.ts, src/agents/embedded-agent-runner/run/preemptive-compaction.ts)
    • Vincent Koc: The shipped v2026.6.6 proof 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)
    • 100yenadmin: They authored the merged context-engine prompt-authority fix that shaped how assembled prompts participate in overflow prechecks. (role: context-engine precheck contributor; confidence: medium; commits: 42584964ac08; files: src/agents/embedded-agent-runner/run/attempt.ts, src/agents/embedded-agent-runner/run/preemptive-compaction.ts)
    • jalehman: They merged the context-engine prompt-authority precheck fix and were the review/routing owner in that PR discussion. (role: reviewer/merger; confidence: medium; commits: 42584964ac08; files: src/agents/embedded-agent-runner/run/attempt.ts, src/agents/embedded-agent-runner/run/preemptive-compaction.ts)
    • openperf: They authored the merged fix that capped compaction reserve behavior for small-context local models such as Ollama. (role: small-context local-model contributor; confidence: medium; commits: 4bc46ccfedc4; files: 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.

  2. added
    P2Normal backlog priority with limited blast radius.
    impact:session-stateSession, memory, transcript, context, or agent state can drift or corrupt.
    on Jun 15, 2026
  3. locked as resolved and limited conversation to collaborators on Jun 25, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    P2Normal backlog priority with limited blast radius.bugSomething isn't workingbug:behaviorIncorrect behavior without a crashimpact:session-stateSession, memory, transcript, context, or agent state can drift or corrupt.

    Type

    No type

    Fields

    Priority

    None yet

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions