Local Models Do Not Have Context Limits Defined, Causing Incorrect Context Usage Display and Potential Overflow
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
- Is
limit.contextthe recommended way to configure local model context windows? - Does intelligent context management use
limit.contextwhen deciding when to checkpoint/reconstruct context? - Is there a default context size used when a local model does not define a limit?
- Could the missing context limit be responsible for context-overflow situations where the backend rejects requests before MiMo performs reconstruction/compaction?
Reproduction
- Configure a local OpenAI-compatible model without a
limitsection. - Start a long-running coding session.
- Observe context percentage in the UI.
- Continue until backend context is exhausted.
- 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