Skip to content

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

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#29354
sjawhar wants to merge 1 commit into
anomalyco:devfrom
sjawhar:feat/config-model-limit-overrides

Conversation

@sjawhar
Copy link
Copy Markdown

@sjawhar sjawhar commented May 26, 2026

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

@github-actions github-actions Bot added the needs:compliance This means the issue will auto-close after 2 hours. label May 26, 2026
@github-actions
Copy link
Copy Markdown
Contributor

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

Based on my search, I found one potentially related PR that warrants mention:

Related PR:

However, the current PR (#29354) itself appears to be the primary implementation for this feature. The search did not reveal any open duplicate PRs that would prevent this from being merged.

@github-actions github-actions Bot removed the needs:compliance This means the issue will auto-close after 2 hours. label May 26, 2026
@github-actions
Copy link
Copy Markdown
Contributor

Thanks for updating your PR! It now meets our contributing guidelines. 👍

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