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
[Bug]: ctx.model.transform serves placeholder limit.context (200000) for config-defined models — percentage-based plugins mis-scale on 1M models #55768
Plugins that read the model registry through ctx.model.transform are served the built-in Model.Info placeholder limit: { context: 200000, output: 32000 } for models explicitly defined in opencode.json with a different limit. Every user-facing surface is correct — GET /api/model and the TUI context indicator report the configured value — so the placeholder is visible to plugins only, and any plugin scaling thresholds from the context window silently works against a window up to 5x too small.
Measured on one process, 11 seconds apart, opencode 2.0.27, model declared with limit: { context: 1000000, output: 393216 }:
plugin @tarquinen/opencode-dcp@3.2.0, its own debug log: Cached model context limit | limit=200000
opencode api GET /api/model: deepseek-api/deepseek-flash -> context=1000000 output=393216
Impact: DCP resolves maxContextLimit: "90%" against 200000, so its "CRITICAL WARNING: MAX CONTEXT LIMIT REACHED / use the compress tool now" nudge fires near 180,000 tokens of a 1M window. A second custom provider (zhipu-api/glm-5.3-flash, also declared 1,000,000) behaves the same, and ~/.local/share/opencode/storage/plugin/dcp/ses_*.json records the nudges (nudges.contextLimitAnchors).
This reads as the same defect as #53477 (auto-closed by the compliance bot on 2026-10-09 with no maintainer reply): Model.Info.default() fills the placeholder, and the config merge that does honor limit.context lands after the editor snapshot plugins read. Related: #40908, #53235 / PR #54398, #35863.
Absolute thresholds on the plugin side avoid the symptom but do not fix the host handoff.
In opencode.json define an OpenAI-compatible provider and a model with an explicit limit, e.g. package "aisdk:@ai-sdk/openai-compatible" and models.bigmodel.limit = { context: 1000000, output: 393216 }.
opencode api GET /api/model reports context=1000000 for it.
Any plugin logging the editor at init shows 200000 instead:
opencodePlugin(async (ctx) => {
ctx.model.transform((editor) => {
for (const m of editor.list()) console.log(${m.providerID}/${m.id}, m.limit.context)
})
})
-> prints 200000 while the registry reports 1000000.
With DCP configured as percentages, the compression nudge then fires at ~18% of the real context window.
Thanks for the detailed report. I can confirm this on 2.0.27, and it still happens on the latest dev (af6ec83).
What I did:
Defined a custom @ai-sdk/openai-compatible provider in opencode.json with a model set to limit: { context: 1000000, output: 393216 }.
Loaded a small local plugin that logs m.limit from inside ctx.model.transform.
Queried GET /api/model on the same server.
The registry reports context=1000000 output=393216. The plugin's transform editor sees context=200000 output=32000, the built-in placeholder. The script below reproduces it.
From reading the code, the config's model limit is applied in a model transform that is deliberately registered after external plugins' transforms. Until then, the model only has the default placeholder, so plugins see 200000 when their transform runs. This is the same problem as #53477, which was closed automatically for not following the issue template. Related: #40908, #53235 / #54398, #35863.
I'll look into seeding configured model limits before external model transforms, while keeping the existing late config override precedence. I'll check the provider/plugin regression tests as well.
Activity
opencode-agent commentedon Oct 15, 2026
Thanks for the detailed report. I can confirm this on 2.0.27, and it still happens on the latest
dev(af6ec83).What I did:
@ai-sdk/openai-compatibleprovider inopencode.jsonwith a model set tolimit: { context: 1000000, output: 393216 }.m.limitfrom insidectx.model.transform.GET /api/modelon the same server.The registry reports
context=1000000 output=393216. The plugin's transform editor seescontext=200000 output=32000, the built-in placeholder. The script below reproduces it.From reading the code, the config's model
limitis applied in a model transform that is deliberately registered after external plugins' transforms. Until then, the model only has the default placeholder, so plugins see 200000 when their transform runs. This is the same problem as #53477, which was closed automatically for not following the issue template. Related: #40908, #53235 / #54398, #35863.Reproduction script (repro.sh)
Run it:
bash repro.shDante-dan commentedon Oct 15, 2026
I'll look into seeding configured model limits before external model transforms, while keeping the existing late config override precedence. I'll check the provider/plugin regression tests as well.