feat(provider): support per-model limit overrides in user config#29354
feat(provider): support per-model limit overrides in user config#29354sjawhar wants to merge 1 commit into
Conversation
|
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. |
|
Thanks for updating your PR! It now meets our contributing guidelines. 👍 |
4a9a23e to
a9fc454
Compare
a9fc454 to
d0db5b1
Compare
d0db5b1 to
d3d48ba
Compare
d3d48ba to
9f3dcb8
Compare
|
Automated PR Cleanup Thank you for contributing to opencode. Due to the high volume of PRs from users and AI agents, we periodically close older PRs using automated criteria so maintainers can focus review time on the most active and community-supported contributions. This PR was closed because it matched the following cleanup criteria:
PRs created within the last month are not affected by this cleanup. If you believe this PR was closed incorrectly, or if you are still actively working on it, please leave a comment explaining why it should be reopened. A maintainer can review and reopen it if appropriate. Thanks again for taking the time to contribute. |
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