Skip to content

feat(provider): support per-model limit overrides in user config#35198

Open
sjawhar wants to merge 1 commit into
anomalyco:devfrom
sjawhar:feat/config-model-limit-overrides
Open

feat(provider): support per-model limit overrides in user config#35198
sjawhar wants to merge 1 commit into
anomalyco:devfrom
sjawhar:feat/config-model-limit-overrides

Conversation

@sjawhar

@sjawhar sjawhar commented Jul 3, 2026

Copy link
Copy Markdown

Issue for this PR

Closes #21564
Refs #8140

Type of change

  • Bug fix
  • New feature

What does this PR do?

Users can already configure custom limits on a model in opencode.json (limit.context, limit.input, limit.output), but those values were being dropped when the model was sourced from models.dev — the materialised model always used the upstream metadata. This blocks workarounds for cases where models.dev lags actual provider behaviour (Copilot models, beta context-window extensions, etc.).

In provider/provider.ts, after the models.dev model is materialised, this merges the configured limit fields over the default values. Each field falls back individually so users can override just one and leave the others at defaults.

Also a small ordering fix in core/models-dev.ts: OPENCODE_DISABLE_MODELS_FETCH was being checked after a fetch attempt could still occur — moved it earlier so it actually short-circuits.

This was previously part of #20671 (closed as mixed scope); this PR contains only the model-limit override piece.

How did you verify your code works?

test/provider/provider.test.ts adds a config provider with limit: { context: 100000, input: 80000, output: 16000 } and asserts the materialised model carries those values. bun typecheck passes.

Checklist

  • I have tested my changes locally
  • I have not included unrelated changes in this PR

Closes #21564

Note: #21564 was closed by the inactivity bot; a maintainer may need to reopen it for the Closes link to take effect on merge. Related: #8140.

Supersedes #29354 (closed by the inactivity bot). Rebased onto latest dev with all merge conflicts resolved; typecheck and targeted tests pass on the fork branch.

@github-actions

github-actions Bot commented Jul 3, 2026

Copy link
Copy Markdown
Contributor

The following comment was made by an LLM, it may be inaccurate:

Based on the search results, here are the potentially related PRs:

Highly Related:

Potentially Related:

These PRs address overlapping concerns around model limit configuration, overrides, and provider-specific model handling. PR #34815 and #32320 appear most closely related as they deal with the same domain of partial/per-variant limit overrides.

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

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

GitHub Copilot plugin ignores user-configured model limit overrides

1 participant