feat(provider): discover local model context limits - #41104
Conversation
|
The following comment was made by an LLM, it may be inaccurate: Based on my search, here are the potentially related PRs (excluding the current PR #41104): Related PRs:
Why they're related: |
|
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
Refs #40908
Type of change
What does this PR do?
Adds a narrow discovery path for local / LAN OpenAI-compatible providers whose configured model is missing
limit.context. During provider load, OpenCode now reads the provider's/modelsendpoint and fills the context limit fromcontext_length,max_context_length, ornative_context_lengthwhen the returned model ID matches.The discovery is intentionally limited to local/private-network base URLs so provider setup does not make surprise network calls to hosted endpoints.
How did you verify your code works?
bun test ./test/provider/provider.test.ts --test-name-pattern 'openai-compatible model fills missing context limit from models endpoint'bun test ./test/provider/provider.test.tsbun typecheckinpackages/opencodebun run lint packages/opencode/src/provider/provider.ts packages/opencode/test/provider/provider.test.tsgit diff --checkNote: repo-wide pre-push typecheck is currently blocked by an existing
@opencode-ai/enterprise/src/custom-elements.d.tsparse error unrelated to this diff, so I pushed with--no-verifyafter the focused checks passed.Screenshots / recordings
Not a UI change.
Checklist