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
models: allow model variants to override limit (context/output) #56582
Model variants can only carry settings, headers, and body — they cannot override a model's limit (context/output tokens). This makes it impossible to offer multiple context-window tiers (e.g. 256K vs 1M) for the same upstream model without duplicating the whole model entry. Some providers expose this as a first-class control (e.g. the CodeBuddy VS Code extension has a per-model "context length" selector), so an equivalent knob in OpenCode would be useful.
Environment
opencode version: 2.0.32
OS: Linux 7.0.0-38-generic (Ubuntu, x86_64)
Terminal: xterm-256color
Shell: /bin/bash
Install/channel: latest (release)
Active plugins: none found in config
Reproduction
Define a custom openai-compatible model in opencode.jsonc with "limit": { "context": 1000000, "output": 131072 }.
Add variants to the same model entry.
Try to give one variant a smaller context budget (e.g. context: 262144) — the variant schema accepts only settings, headers, and body, so limit cannot be varied.
Expected Behavior
Variant-level limit override (merge order provider → model → variant), so a single catalog entry can expose context tiers:
limit.context is used by OpenCode for context accounting / compaction timing, so a smaller tier genuinely changes behavior, not just display.
The motivating setup is a custom openai-compatible provider where the backend serves the same model at different context budgets (CodeBuddy's client picks per request; OpenCode currently can't).
Thanks for the detailed request! You're asking for model variants to be able to override limit (context/output), merged provider → model → variant. That way one model entry could offer context tiers such as codebuddy/glm-5.3-flash#1m and #256k without a duplicate entry for each tier.
You're right about how it works now: in v2, variants only merge settings, headers and body, and context accounting and compaction always use the base model's limit. A plugin can't do this today either. The plugin provider.models hook can only add whole model entries, which is the same duplication you're trying to avoid. The maintainers will consider this.
Activity
opencode-agent commentedon Oct 17, 2026
Thanks for the detailed request! You're asking for model variants to be able to override
limit(context/output), merged provider → model → variant. That way one model entry could offer context tiers such ascodebuddy/glm-5.3-flash#1mand#256kwithout a duplicate entry for each tier.You're right about how it works now: in v2, variants only merge
settings,headersandbody, and context accounting and compaction always use the base model'slimit. A plugin can't do this today either. The pluginprovider.modelshook can only add whole model entries, which is the same duplication you're trying to avoid. The maintainers will consider this.Related issues:
limitoverride request, filed against v1 and closed there