Skip to content

[FEATURE]: Fill context limits for OpenAI-compatible providers from their /models advertisement #53235

Closed as duplicate

Description

@woodsonl
  • 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

PR: #53236

Activity

  1. github-actions commented on Oct 4, 2026

    @github-actions
    Contributor

    This issue does not fully meet our contributing guidelines.

    What needs to be fixed:

    • 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.

  2. 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
  3. github-actions commented on Oct 4, 2026

    @github-actions
    Contributor

    Thanks for updating the issue with the Feature Request details, reproduction steps, and system information!

  4. Tarquinen commented on Oct 20, 2026

    @Tarquinen
    Member

    We're tracking this in #40908, so I'm closing this as a duplicate. Please follow that issue for updates.

    — from 𝕺𝖕𝖊𝖓𝕮𝖔𝖉𝖊

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions