feat(provider): support per-model limit overrides in user config#35198
Open
sjawhar wants to merge 1 commit into
Open
feat(provider): support per-model limit overrides in user config#35198sjawhar wants to merge 1 commit into
sjawhar wants to merge 1 commit into
Conversation
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. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Issue for this PR
Closes #21564
Refs #8140
Type of change
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_FETCHwas 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.tsadds a config provider withlimit: { context: 100000, input: 80000, output: 16000 }and asserts the materialised model carries those values.bun typecheckpasses.Checklist
Closes #21564
Note: #21564 was closed by the inactivity bot; a maintainer may need to reopen it for the
Closeslink to take effect on merge. Related: #8140.Supersedes #29354 (closed by the inactivity bot). Rebased onto latest
devwith all merge conflicts resolved; typecheck and targeted tests pass on the fork branch.