MiMo-Code icon indicating copy to clipboard operation
MiMo-Code copied to clipboard

Local Models Do Not Have Context Limits Defined, Causing Incorrect Context Usage Display and Potential Overflow

Open charly1r opened this issue 5 months ago • 0 comments

Description

Local Models Do Not Have Context Limits Defined, Causing Incorrect Context Usage Display and Potential Overflow

Description

When using local OpenAI-compatible providers (llama.cpp in my case), MiMoCode does not appear to automatically know the model's actual context window.

As a result, the context usage indicator can be significantly incorrect, and context management may not trigger appropriately before the backend limit is reached.

Environment

  • MiMoCode: current release
  • Provider: OpenAI-compatible (llama.cpp server)
  • Backend context size: 180224 tokens
  • Model: Qwen3.6-35B-A3B-REAM-192-Q4_K_M

Observed Behavior

After configuring a local model without a limit section:

"Qwen3.6-35B-A3B-REAM-192-Q4_K_M": {
  "name": "Qwen3.6-35B-A3B-REAM-192-Q4_K_M"
}

MiMo displayed:

Context
22026 tokens
2% used

However, the backend context window was only:

180224 tokens

22k tokens is approximately 12% of 180k, not 2%.

Later in a long-running coding session, the backend failed with:

request (181631 tokens) exceeds the available context size (180224 tokens)

The agent repeatedly retried the request and became stuck.

Investigation

I manually added limits to the local model definition:

"Qwen3.6-35B-A3B-REAM-192-Q4_K_M": {
  "name": "Qwen3.6-35B-A3B-REAM-192-Q4_K_M",
  "limit": {
    "context": 180224,
    "output": 32000
  }
}

After restarting MiMo, the UI changed to:

Context
20958 tokens
12% used

which correctly matches:

20958 / 180224 ≈ 11.6%

This suggests MiMo is using the configured limit.context value for context accounting.

Expected Behavior

For local/OpenAI-compatible models:

  • MiMo should either detect the model context window automatically, or
  • provide a documented way to configure it.

Additionally, intelligent context management/checkpointing should use the actual backend context size rather than an assumed/default value.

Questions

  1. Is limit.context the recommended way to configure local model context windows?
  2. Does intelligent context management use limit.context when deciding when to checkpoint/reconstruct context?
  3. Is there a default context size used when a local model does not define a limit?
  4. Could the missing context limit be responsible for context-overflow situations where the backend rejects requests before MiMo performs reconstruction/compaction?

Reproduction

  1. Configure a local OpenAI-compatible model without a limit section.
  2. Start a long-running coding session.
  3. Observe context percentage in the UI.
  4. Continue until backend context is exhausted.
  5. Compare behavior with and without:
"limit": {
  "context": 180224,
  "output": 32000
}

Plugins

No response

OpenCode version

No response

Steps to reproduce

No response

Screenshot and/or share link

No response

Operating System

No response

Terminal

No response

charly1r avatar Jun 13 '26 16:06 charly1r