You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
[Bugs]: Context window is hardcoded to 200k for many models instead of resolving dynamically from actual provider/model metadata #35863
OpenCode's context window handling relies on static/hardcoded values (models.generated.js / models.dev
catalog snapshots) instead of resolving each model's actual context window dynamically. This causes
auto-compaction, context tracking, and overflow checks to trigger far too early — even when the
selected model supports a much larger context (e.g. 1M).
This is not isolated to one provider — the same root cause shows up across multiple models:
Expected Behavior:
Context window per model should be resolved dynamically — either from the provider's live /models
endpoint when available, or from an up-to-date, easily-updatable model registry — instead of a
hardcoded fallback (200k) baked into the binary. This applies to ALL models/providers, not just
Anthropic's context1m case.
Actual Behavior:
Context window limit is compiled/cached at build time per model. When a provider updates a model's
actual context window (larger or smaller), OpenCode keeps using the stale hardcoded value until a
new release ships.
Proposed Solution:
Attempt to fetch context window from the provider's live model-list API at session start (with caching)
Fall back to a versioned, community-updatable model registry (not compiled into the binary) when
live discovery isn't available
Only fall back to a generic default (e.g. 200k) as a last resort, with a visible warning in TUI/GUI
so users know the value is an estimate, not the real limit
Respect user-defined limit.context overrides in opencode.json above all of the above (already
partially supported)
Select a model whose real provider-side context window differs from OpenCode's compiled/cached value
(e.g. any model with context1m enabled, or DeepSeek-V4-Pro, or GPT-5.5 Codex)
Run a long session and monitor the context/compaction tracker in TUI
Observe compaction/overflow triggers at ~200k (or another stale hardcoded value) instead of the
model's actual advertised context window
In my case stopped at around 151K / 17% when using deepseek-v4-pro and forced a compaction. Some times it seems even earlier. Tried overriding the config in opencode json with the following - but it has no effect:
One of the main reasons I subscribed to OpenCode Go was to use the full context window advertised by models such as DeepSeek V4 Pro, GLM-5.2, and Qwen3.7 Max.
Using only ~190K for models that officially support 1M tokens is a significant limitation for long development sessions.
It would be great if OpenCode could either:
expose the full supported context window when the backend supports it, or
clearly indicate the actual context limit for the selected backend.
Thank you!
Reacted by Jc Miñarro, DarkskyX, Kiwi, MuhaddiMu and Bleach665
Activity
bjornnorman commentedon Jul 27, 2026
In my case stopped at around 151K / 17% when using deepseek-v4-pro and forced a compaction. Some times it seems even earlier. Tried overriding the config in opencode json with the following - but it has no effect:
"deepseek": { "models": { "deepseek-v4-pro": { "limit": { "context": 1048576, "input": 1048576, "output": 262144 } } } }I'm on the latest version of Opencode: 1.18.7
ulascanndmrc commentedon Jul 30, 2026
I would also like to support this request.
One of the main reasons I subscribed to OpenCode Go was to use the full context window advertised by models such as DeepSeek V4 Pro, GLM-5.2, and Qwen3.7 Max.
Using only ~190K for models that officially support 1M tokens is a significant limitation for long development sessions.
It would be great if OpenCode could either:
Thank you!
github-actions commentedon Sep 30, 2026
To stay organized issues are automatically closed after 60 days of no activity. If the issue is still relevant please open a new one.