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
[FEATURE]: Fill context limits for OpenAI-compatible providers from their /models advertisement #53235
I have verified this feature I'm about to request hasn't been suggested before.
Describe the enhancement you want to request
Custom @ai-sdk/openai-compatible providers are not in models.dev. Without a hand-written limit block for every model, OpenCode has no context window for them and auto-compaction cannot know when to fire. Long sessions grow until the upstream rejects them with context_length_exceeded.
Most OpenAI-compatible servers (vLLM, LM Studio, LiteLLM, Ollama, OpenRouter) already publish per-model context_length / max_input_tokens / max_output_tokens on GET {baseURL}/models. OpenCode could fill the missing limits from there, with a config limit still winning.
Reproduction
Configure an openai-compatible provider with one model and no limit, point it at a server that advertises limits, run a long session. Compaction never triggers and the upstream eventually 400s. Earlier 2.x releases defaulted unknown models to a 200k context, which compacted at the wrong point for 1M-window models.
System details
OpenCode: 2.0.22 (desktop bundle CLI); verified against dev @ 907b3bc
OS/client: macOS 15, desktop app and CLI sessions
Provider: self-hosted OpenAI-compatible proxy (OmniRoute) serving 1M-context GLM 5.3 and 262k-context DeepSeek models; applies equally to vLLM / LM Studio / LiteLLM / Ollama endpoints
This proposes new behavior (reading model limits from /models), so please use the Feature Request template: start the title with [FEATURE]: and include the required verification checkbox.
Add system details to help reproduce the issue, especially the OpenCode version, OS/client, and the OpenAI-compatible provider/server and version.
Please edit this issue to address the above within 72 hours, or it will be automatically closed.
This issue might be a duplicate of existing issues. Please check:
#40908: Requests dynamic context-limit detection from OpenAI-compatible providers via /models.
#52346: Requests automatic context-window detection from providers, including OpenAI-compatible /models metadata.
If you believe this was flagged incorrectly, please let a maintainer know.
changed the title [-]OpenAI-compatible providers: advertised context limits on /models are ignored, so auto-compaction never fires[/-][+][FEATURE]: Fill context limits for OpenAI-compatible providers from their /models advertisement[/+]on Oct 4, 2026
Activity
github-actions commentedon Oct 4, 2026
This issue does not fully meet our contributing guidelines.
What needs to be fixed:
/models), so please use the Feature Request template: start the title with[FEATURE]:and include the required verification checkbox.Please edit this issue to address the above within 72 hours, or it will be automatically closed.
This issue might be a duplicate of existing issues. Please check:
/models./modelsmetadata.If you believe this was flagged incorrectly, please let a maintainer know.
[-]OpenAI-compatible providers: advertised context limits on /models are ignored, so auto-compaction never fires[/-][+][FEATURE]: Fill context limits for OpenAI-compatible providers from their /models advertisement[/+]github-actions commentedon Oct 4, 2026
Thanks for updating the issue with the Feature Request details, reproduction steps, and system information!
Tarquinen commentedon Oct 20, 2026
We're tracking this in #40908, so I'm closing this as a duplicate. Please follow that issue for updates.
— from 𝕺𝖕𝖊𝖓𝕮𝖔𝖉𝖊