fix(provider): discover LM Studio models from /v1/models#26756
fix(provider): discover LM Studio models from /v1/models#26756ipogosov wants to merge 3 commits into
Conversation
|
The following comment was made by an LLM, it may be inaccurate: Based on my search, I found several related PRs that address LM Studio model discovery features. However, excluding the current PR #26756, these are all historical PRs (from 2024 and earlier) that were either merged or closed: Related PRs (not current duplicates):
These appear to be earlier attempts or partial implementations of similar functionality. The current PR #26756 seems to be a comprehensive implementation that addresses issue #2047 specifically. No duplicate PRs found among currently open PRs. |
|
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 #2047
Type of change
What does this PR do?
OpenCode currently relies on its static models catalog for the LM Studio provider, so models the user has loaded or unloaded inside LM Studio are not reflected in OpenCode until the catalog is updated and shipped. This is the bug described in #2047 —
auth logout/auth logindoes not refresh the visible model list because nothing actually consults LM Studio.This PR makes the LM Studio provider discover its own models at runtime from the live OpenAI-compatible
/v1/modelsendpoint and use that response as the source of truth for visible models:<lmstudio-base-url>/v1/modelswhenever its model list is requested, and uses the IDs it gets back to drive what OpenCode shows. Stale catalog-only entries that LM Studio no longer reports are pruned, so unloading or removing a model in LM Studio actually removes it from OpenCode.options.discoverModels: falsefor users who prefer the previous "trust the catalog" behavior or who can't reach/v1/modelsfrom where OpenCode runs.options.includeEmbeddingModels: truere-includes them for users who want to wire them up explicitly.The change is scoped to the LM Studio provider; other providers' model resolution paths are not touched.
How did you verify your code works?
bun typecheckfrompackages/opencodebun test --timeout 30000 test/provider/provider.test.ts— new tests cover the discovery happy path, the prune-stale-catalog-entries case, the config-overrides-discovered-model case, thediscoverModels: falseopt-out, and the embedding-filter /includeEmbeddingModels: truecasesbun run build --single --skip-installto confirm the standalone build still produces an executable with the change in placebun turbo typecheckacross the workspaceScreenshots / recordings
N/A, non-UI change. The visible effect is in OpenCode's model picker reflecting LM Studio's actual loaded set.
Checklist