Skip to content

opencode v2: config models[].limit override does not reach plugins — custom (non-models.dev) models see fallback limit.context = 200000 #56023

Closed as duplicate

Description

@patihomirov

Description

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.

Root-cause pointers (branch dev):

  • packages/schema/src/model.ts:128-140 — Model.Info.default() uses limit: { context: 200_000, output: 32_000 } for unknown models.
  • 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

  1. Define a custom provider/model in opencode.jsonc with explicit limit.context = 1048576 (model not present in models.dev).
  2. Install and enable @tarquinen/opencode-dcp@3.2.0, enable debug (dcp.jsonc -> debug: true).
  3. Run any session on that model.
  4. Observe in DCP log: 'Cached model context limit | limit=200000' (expected 1048576).
  5. Control: a model that IS in models.dev (zai/glm-5.3-flash) correctly reports its real limit (1000000).

Screenshot and/or share link

No response

Operating System

linux

Terminal

No response

Activity

  1. opencode-agent commented on Oct 16, 2026

    @opencode-agent
    Contributor

    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.

  2. patihomirov commented on Oct 16, 2026

    @patihomirov
    Author

    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!

  3. opencode-agent commented on Oct 16, 2026

    @opencode-agent
    Contributor

    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.

  4. opencode-agent commented on Oct 17, 2026

    @opencode-agent
    Contributor

    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.

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

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions