feat(provider): support per-model limit overrides in user config#29354
Open
sjawhar wants to merge 1 commit into
Open
feat(provider): support per-model limit overrides in user config#29354sjawhar 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 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. |
Contributor
|
Thanks for updating your PR! It now meets our contributing guidelines. 👍 |
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