GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — fix(provider): discover LM Studio models from /v1/models by ipogosov · Pull Request #26756 · anomalyco/opencode

Conversation

@ipogosov

@ipogosov ipogosov commented May 10, 2026

Copy link
Copy Markdown

Issue for this PR

Closes #2047

Type of change

  • Bug fix
  • New feature
  • Refactor / code improvement
  • Documentation

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 login does 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/models endpoint and use that response as the source of truth for visible models:

  • The provider hits <lmstudio-base-url>/v1/models whenever 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.
  • Configured model metadata (display names, context window, capability flags, etc.) is preserved as overrides: a discovered model that also exists in the user's config inherits that config's fields, so manual tuning is not blown away by discovery.
  • Discovery has a safe opt-out via options.discoverModels: false for users who prefer the previous "trust the catalog" behavior or who can't reach /v1/models from where OpenCode runs.
  • Obvious embedding and rerank models are filtered out of the discovered list by default (so the chat picker isn't polluted with non-chat models); options.includeEmbeddingModels: true re-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 typecheck from packages/opencode
  • bun 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, the discoverModels: false opt-out, and the embedding-filter / includeEmbeddingModels: true cases
  • bun run build --single --skip-install to confirm the standalone build still produces an executable with the change in place
  • pre-push hook: bun turbo typecheck across the workspace
  • Manually exercised against a local LM Studio instance: loading and unloading models in LM Studio now shows up in OpenCode's model picker without restart / re-login

Screenshots / recordings

N/A, non-UI change. The visible effect is in OpenCode's model picker reflecting LM Studio's actual loaded set.

Checklist

  • I have tested my changes locally
  • I have not included unrelated changes in this PR

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

SamuelYiuSY reacted with thumbs up emoji
All reactions
  • 👍 1 reaction
Иван Погосов Иван Погосов
Add LM Studio model discovery
a17e167
@github-actions

github-actions Bot commented May 10, 2026

Copy link
Copy Markdown
Contributor

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):

  • feat: added ability to load dynamically the model list from LM Studio #24612 - "feat: added ability to load dynamically the model list from LM Studio"
  • feat(provider): native lm studio auto-discovery #20524 - "feat(provider): native lm studio auto-discovery"
  • feat(opencode): add local server provider with auto model discovery #19959 - "feat(opencode): add local server provider with auto model discovery"
  • feat(opencode): OpenRouter model discovery/pruning at runtime #20004 - "feat(opencode): OpenRouter model discovery/pruning at runtime"
  • feat(opencode): add dynamic configuration and context discovery for LM Studio #15732 - "feat(opencode): dynamic configuration and context discovery for LM Studio"
  • feat(opencode): dynamic model discovery for local providers (LM Studio, llama.cpp, etc.) #17670 - "feat(opencode): dynamic model discovery for local providers"
  • fix(provider): stabilize LM Studio Qwen requests #26744 - "fix(provider): stabilize LM Studio Qwen requests" (recent, but different scope)

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.

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

Иван Погосов added 2 commits May 11, 2026 03:15
Иван Погосов Иван Погосов
Preserve LM Studio cache markers
32c5f9f
Иван Погосов Иван Погосов
Avoid replaying failed prompt turns
c5c1de5
This was referenced May 11, 2026
📊 AI CLI 工具社区动态日报 2026-05-11 zx0828/big_model_radar#49
Open
feat(opencode): local LAN provider discovery + auto-discover models #27554
Closed
@github-actions

github-actions Bot commented Jun 10, 2026

Copy link
Copy Markdown
Contributor

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:

  • The PR was created more than 1 month ago
  • The PR had fewer than 2 positive reactions
  • Positive reactions are counted as thumbs-up, heart, celebration, or rocket reactions on the PR

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.

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@github-actions github-actions Bot closed this Jun 10, 2026
@github-actions github-actions Bot added the automated-pr-cleanup label Jun 10, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Reviewers

No reviews

Uh oh!

There was an error while loading. Please reload this page.

Assignees

No one assigned

Labels

automated-pr-cleanup

Projects

None yet

Milestone

No milestone

Development

Successfully merging this pull request may close these issues.

LM Studio Failure to refresh models

Uh oh!

There was an error while loading. Please reload this page.

1 participant

@ipogosov
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.
You are visitor 01402775 — GeezerVison does not store the pages you look up.
Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.