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
opencode v2: config models[].limit override does not reach plugins — custom (non-models.dev) models see fallback limit.context = 200000 #56023
Summary: For models missing from models.dev (e.g. custom ozon/* models declared in opencode.jsonc provider with explicit limit.context: 1048576), the plugin hook receives model.limit.context = 200000 (the Model.Info.default() fallback), not the configured value. A model that IS in models.dev (zai/glm-5.3-flash) correctly reports 1000000. No 1048576 ever appears.
packages/core/src/config/plugin/provider.ts:95-97 and :159 — the config override mechanism model.limit = { ...model.limit, ...config.limit } exists.
packages/core/src/config/plugin/provider.ts:105 — config overrides are intentionally registered AFTER external (plugin) model transforms.
packages/core/src/session/model-request.ts:241,256,422-424 — native v2 session hooks (session.context/generate/compaction) carry only model: Model.Ref — no limit at all — so plugins must read the model catalogue themselves (as DCP does via ctx.model.transform(editor => editor.list())), where the config override may not be applied yet.
services/www/src/docs/content/build/plugins/migrate-v1.mdx:161 — experimental.chat.system.transform maps to ctx.session.hook("context", ...).
Observed evidence: DCP v3.2.0 logs 'Cached model context limit | limit=200000' for every session on custom models (lib/hooks.ts:65-70, reading input.model.limit.context from the hook event; v2 path caches the same value from ctx.model.transform(editor => editor.list()), lib/v2/index.ts:168-172).
Expected: plugins should observe the final limit after the config override is applied (or a clearly documented mechanism for user-defined model substitution), so they can compute thresholds against the real context window.
Impact: any plugin using model.limit.context computes percentage/domain thresholds against the understated 200k instead of the real limit -> premature triggers (DCP: 90% x 200k ~ 180k instead of ~ 943k).
Workaround (adopted in DCP): configure absolute numeric thresholds instead of percentages.
Related:#53477 (auto-closed as not planned — same root cause submitted with a non-compliant template; plugin-visible model.limit.context equals the 200,000 Model.Info.default() placeholder for config-defined models, corrected value only reaches the final registry). See also #21564 and #29555 (related configured-limit symptoms).
Plugins
@tarquinen/opencode-dcp@3.2.0
OpenCode version
opencode 2.0.30
Steps to reproduce
Define a custom provider/model in opencode.jsonc with explicit limit.context = 1048576 (model not present in models.dev).
Install and enable @tarquinen/opencode-dcp@3.2.0, enable debug (dcp.jsonc -> debug: true).
Run any session on that model.
Observe in DCP log: 'Cached model context limit | limit=200000' (expected 1048576).
Control: a model that IS in models.dev (zai/glm-5.3-flash) correctly reports its real limit (1000000).
Thanks for the detailed write-up and the pointers into the code. I think this is a duplicate of #55768. That issue reports the same thing: ctx.model.transform gives plugins the placeholder limit.context = 200000 instead of the configured limit for config-defined models, with the same DCP 3.2.0 Cached model context limit | limit=200000 log.
A fix was merged in #55778 (it applies configured limits before plugin model transforms run). It landed on dev shortly after 2.0.30 was tagged, so 2.0.30 doesn't include it yet. It should be in the next release after 2.0.30.
Related issues, ordered from most to least likely to match:
The bot will close this issue as a duplicate in 1 day unless you reply explaining how your problem is different, for example if it still happens on a release that includes #55778.
Acknowledged — closing as a duplicate of #55768 is fine. PR #55778 (fix(core): seed configured limits before model transforms) fully covers this case (DCP reads model.limit.context via ctx.model.transform → editor.list(); the seed-first pass makes the configured limit.context=1048576 reach plugins before external transforms).
One note for release tracking: the fix is merged on dev but is not in any released tag yet — verified that both v2.0.30 and v1.19.2 lack the early seed pass. Our environment currently runs 2.0.30, where the bug still reproduces (DCP debug log: Cached model context limit | limit=200000). We will re-test once a release containing #55778 ships. Until then the workaround (absolute DCP token limits, see #53477) is in place. Thanks!
Thanks for confirming, and for checking the release tags. You're right: #55778 landed on dev after v2.0.30 was tagged, so no released version has it yet. Absolute DCP token thresholds are a good workaround until then. If the 200000 placeholder still shows up on a release that includes #55778, please comment on #55768 or open a new issue. This issue will be closed as a duplicate of #55768 as planned.
Closing this as a duplicate of #55768, as discussed. The fix (#55778, which applies configured limit values before plugin model transforms run) is merged on dev but isn't in a release yet, including 2.0.30. Thanks again for the detailed report and for checking the release tags. If plugins still see the 200000 placeholder on a release that includes #55778, please comment on #55768 or open a new issue.
Activity
opencode-agent commentedon Oct 16, 2026
Thanks for the detailed write-up and the pointers into the code. I think this is a duplicate of #55768. That issue reports the same thing:
ctx.model.transformgives plugins the placeholderlimit.context = 200000instead of the configured limit for config-defined models, with the same DCP 3.2.0Cached model context limit | limit=200000log.A fix was merged in #55778 (it applies configured limits before plugin model transforms run). It landed on
devshortly after 2.0.30 was tagged, so 2.0.30 doesn't include it yet. It should be in the next release after 2.0.30.Related issues, ordered from most to least likely to match:
limit.context(200,000) for config-defined models at plugin init — corrected value only reaches the final registry #53477: earlier report of the same bug, auto-closed because it didn't use the issue templateThe bot will close this issue as a duplicate in 1 day unless you reply explaining how your problem is different, for example if it still happens on a release that includes #55778.
patihomirov commentedon Oct 16, 2026
Acknowledged — closing as a duplicate of #55768 is fine. PR #55778 (
fix(core): seed configured limits before model transforms) fully covers this case (DCP readsmodel.limit.contextviactx.model.transform→editor.list(); the seed-first pass makes the configuredlimit.context=1048576reach plugins before external transforms).One note for release tracking: the fix is merged on
devbut is not in any released tag yet — verified that bothv2.0.30andv1.19.2lack the early seed pass. Our environment currently runs2.0.30, where the bug still reproduces (DCP debug log:Cached model context limit | limit=200000). We will re-test once a release containing #55778 ships. Until then the workaround (absolute DCP token limits, see #53477) is in place. Thanks!opencode-agent commentedon Oct 16, 2026
Thanks for confirming, and for checking the release tags. You're right: #55778 landed on
devafterv2.0.30was tagged, so no released version has it yet. Absolute DCP token thresholds are a good workaround until then. If the 200000 placeholder still shows up on a release that includes #55778, please comment on #55768 or open a new issue. This issue will be closed as a duplicate of #55768 as planned.opencode-agent commentedon Oct 17, 2026
Closing this as a duplicate of #55768, as discussed. The fix (#55778, which applies configured
limitvalues before plugin model transforms run) is merged ondevbut isn't in a release yet, including 2.0.30. Thanks again for the detailed report and for checking the release tags. If plugins still see the 200000 placeholder on a release that includes #55778, please comment on #55768 or open a new issue.