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 — feat(provider): native lm studio auto-discovery by Aarogaming · Pull Request #20524 · anomalyco/opencode

Conversation

@Aarogaming

@Aarogaming Aarogaming commented Apr 1, 2026 •
edited
Loading

Uh oh!

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

Copy link
Copy Markdown

Issue for this PR

Closes #20609

Type of change

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

What does this PR do?

Adds native auto-discovery for LM Studio instances running locally, streamlining user experience for offline models.

How did you verify your code works?

Ran the local LM Studio instance and confirmed the opencode provider system properly discovered the local models without manual URL entry. Typecheck and unit tests were updated.

Screenshots / recordings

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.

kolya182 reacted with thumbs up emoji
All reactions
  • 👍 1 reaction
Aarogaming added 2 commits March 28, 2026 22:07
@Aarogaming
feat: native LM Studio support with dynamic model discovery
cc49be0
@Aarogaming
fix: unescape template literals in provider.ts
fb7aa6a
Copilot AI review requested due to automatic review settings April 1, 2026 17:59
@github-actions

github-actions Bot commented Apr 1, 2026

Copy link
Copy Markdown
Contributor

The following comment was made by an LLM, it may be inaccurate:

Potential Duplicate/Related PRs Found

I found two highly related PRs that may be addressing similar functionality:

  1. PR feat(opencode): dynamic model discovery for local providers (LM Studio, llama.cpp, etc.) #17670 - feat(opencode): dynamic model discovery for local providers (LM Studio, llama.cpp, etc.)

    • feat(opencode): dynamic model discovery for local providers (LM Studio, llama.cpp, etc.) #17670
    • Likely related: Addresses dynamic model discovery for LM Studio and other local providers
  2. PR feat(opencode): add local server provider with auto model discovery #19959 - feat(opencode): add local server provider with auto model discovery

    • feat(opencode): add local server provider with auto model discovery #19959
    • Likely related: Implements auto model discovery for local server providers
  3. PR feat(opencode): add dynamic configuration and context discovery for LM Studio #15732 - feat(opencode): add dynamic configuration and context discovery for LM Studio

    • feat(opencode): add dynamic configuration and context discovery for LM Studio #15732
    • Possibly related: Earlier work on LM Studio dynamic configuration and discovery

Why they might be duplicates: These PRs all address auto-discovery functionality for LM Studio and local model providers. You should verify whether PR #20524 is a newer/improved version of this functionality or if there's overlap that needs to be resolved.

All reactions

Sorry, something went wrong.

Uh oh!

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

Copilot started reviewing on behalf of Aarogaming April 1, 2026 18:00
View session
Copilot AI reviewed Apr 1, 2026
View reviewed changes

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

There was a problem hiding this comment.

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Adds an LM Studio provider integration intended to auto-discover locally running LM Studio instances and expose their models via the existing OpenAI-compatible provider plumbing.

Changes:

  • Registers a new lmstudio provider mapping to the bundled OpenAI-compatible SDK.
  • Adds a CUSTOM_LOADERS.lmstudio() loader that sets default connection options and implements /models discovery.
  • Generates model metadata for discovered LM Studio models (capabilities, limits, cost, etc.).

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Sorry, something went wrong.

Uh oh!

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

All reactions
Comment thread packages/opencode/src/provider/provider.ts
Comment on lines +163 to +166
async discoverModels() {
try {
const res = await fetch(`${baseURL}/models`)
if (!res.ok) return {}

Copilot AI Apr 1, 2026

Copy link

There was a problem hiding this comment.

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

discoverModels() is wired into CUSTOM_LOADERS, but provider state currently only invokes discoveryLoaders[...]() for GitLab. As-is, LM Studio models returned here will never be merged into providers["lmstudio"].models, so the advertised auto-discovery won’t actually surface any models. Consider generalizing the discovery step to run for any provider with a discoverModels loader (and merge results) before the empty-models filter, or add an explicit LM Studio discovery/merge like the GitLab block.

Sorry, something went wrong.

Uh oh!

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

All reactions
Copilot uses AI. Check for mistakes.
Comment thread packages/opencode/src/provider/provider.ts

const prettyName = m.id.split("/").pop() || m.id

models[`lmstudio/${m.id}`] = {

Copilot AI Apr 1, 2026

Copy link

There was a problem hiding this comment.

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The discovered models map uses keys like lmstudio/${m.id} but sets providerID: "lmstudio". Provider model maps elsewhere use unprefixed model IDs as keys (the provider already scopes them), and parseModel() splits provider/model strings. With the current key format, model lookup/selection is likely to break (especially when m.id already contains /). Use m.id as the map key (scoped by provider) and keep the model id consistent with that key.

Suggested change
models[`lmstudio/${m.id}`] = {
models[m.id] = {

Sorry, something went wrong.

Uh oh!

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

All reactions
Copilot uses AI. Check for mistakes.
Comment thread packages/opencode/src/provider/provider.ts
Comment on lines +160 to +161
return {
autoload: true,

Copilot AI Apr 1, 2026

Copy link

There was a problem hiding this comment.

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

autoload: true here enables the LM Studio provider unconditionally whenever it exists in the models.dev database, even when the local LM Studio server isn’t running (in which case discoverModels() returns {}). That can expose non-functional models in the UI and lead to confusing runtime errors. Consider making autoload conditional on a quick reachability check / successful discovery (or only autoload after discovery yields at least one model).

Suggested change
return {
autoload: true,
// Determine whether LM Studio is reachable and has at least one model.
let autoload = false
try {
const res = await fetch(`${baseURL}/models`)
if (res.ok) {
const data = (await res.json()) as any
const hasModels = Array.isArray(data?.data) && data.data.length > 0
autoload = hasModels
}
} catch {
autoload = false
}
return {
autoload,

Sorry, something went wrong.

Uh oh!

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

All reactions
Copilot uses AI. Check for mistakes.
Comment thread packages/opencode/src/provider/provider.ts
options: { baseURL, apiKey: "lm-studio" },
async discoverModels() {
try {
const res = await fetch(`${baseURL}/models`)

Copilot AI Apr 1, 2026

Copy link

There was a problem hiding this comment.

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

fetch(${baseURL}/models) has no timeout/abort signal. If LM Studio is bound but slow/hung, provider initialization could block state loading indefinitely. Consider adding an AbortSignal.timeout(...) (and handling abort) to keep startup responsive.

Suggested change
const res = await fetch(`${baseURL}/models`)
const timeoutSignal =
typeof AbortSignal !== "undefined" && "timeout" in AbortSignal
? AbortSignal.timeout(5000)
: undefined
const res = await fetch(
`${baseURL}/models`,
timeoutSignal ? { signal: timeoutSignal } : undefined
)

Sorry, something went wrong.

Uh oh!

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

All reactions
Copilot uses AI. Check for mistakes.
@Aarogaming
fix(ci): disable E2E paid requirement for PR forks
d380394
@Aarogaming
Aarogaming requested a review from adamdotdevin as a code owner April 1, 2026 18:28
@Aarogaming
fix(ci): sync test.yml with dev to remove e2e paid requirement
3e1f798
@opencode-agent
opencode-agent Bot force-pushed the dev branch from 2f2ed11 to 9f201d6 Compare April 16, 2026 21:55
@github-actions github-actions Bot mentioned this pull request Apr 27, 2026
feat: added ability to load dynamically the model list from LM Studio #24612
Closed
3 of 6 tasks
This was referenced May 10, 2026
fix(provider): discover LM Studio models from /v1/models #26756
Closed
feat(opencode): local LAN provider discovery + auto-discover models #27554
Closed
@rekram1-node

rekram1-node commented May 15, 2026

Copy link
Copy Markdown
Member

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.

@rekram1-node rekram1-node closed this May 15, 2026
@rekram1-node rekram1-node added the automated-pr-cleanup label May 15, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Reviewers

Copilot code review Copilot
Copilot review effort
Applies to this pull request for everyone.Learn more about Copilot code review.
Copilot left review comments
@adamdotdevin adamdotdevin Awaiting requested review from adamdotdevin

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.

Feature Request: Native LM Studio auto-discovery

Uh oh!

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

3 participants

@Aarogaming @rekram1-node
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.