Skip to content

feat(opencode): add local server provider with auto model discovery#17688

Closed
hmblair wants to merge 2 commits intoanomalyco:devfrom
hmblair:autoload-models
Closed

feat(opencode): add local server provider with auto model discovery#17688
hmblair wants to merge 2 commits intoanomalyco:devfrom
hmblair:autoload-models

Conversation

@hmblair
Copy link

@hmblair hmblair commented Mar 16, 2026

Closes #6231

Type of change

New feature

What it does

Adds a built-in local provider that automatically discovers models from any OpenAI-compatible /models endpoint. Configure a baseURL, and the provider fetches available models at startup — no manual model listing required.

Also fixes the CUSTOM_LOADERS loop to allow custom loaders that don't have a models.dev entry (previously they were silently skipped).

Why this approach

PR #17670 solves the same problem with 700+ lines across 3 files and a new dynamicModelList config flag. This PR does it in ~50 lines with no new config surface. The local provider is a first-class built-in: it hits /models, registers whatever it finds, and returns autoload: true. If the endpoint is unreachable or returns nothing useful, it silently returns autoload: false. Nothing new to learn, nothing to break.

How to use it

{
  "provider": {
    "local": {
      "options": {
        "baseURL": "http://localhost:11434/v1"
      }
    }
  }
}

With an API key (e.g. LM Studio):

{
  "provider": {
    "local": {
      "options": {
        "baseURL": "http://localhost:1234/v1",
        "apiKey": "lm-studio"
      }
    }
  }
}

Tests

Three tests covering successful discovery, unreachable endpoint, and missing baseURL.

Add a custom loader for a "local" provider that auto-discovers models
from any OpenAI-compatible local server (llama.cpp, ollama, vLLM, LM
Studio, etc.) by querying the standard /v1/models endpoint at startup.

Users configure only a baseURL and optional apiKey — no manual model
listing required. Discovered models are merged with any manually
configured models without overwriting them.

Closes anomalyco#6231
@github-actions
Copy link
Contributor

Hey! Your PR title Add local server provider with auto model discovery doesn't follow conventional commit format.

Please update it to start with one of:

  • feat: or feat(scope): new feature
  • fix: or fix(scope): bug fix
  • docs: or docs(scope): documentation changes
  • chore: or chore(scope): maintenance tasks
  • refactor: or refactor(scope): code refactoring
  • test: or test(scope): adding or updating tests

Where scope is the package name (e.g., app, desktop, opencode).

See CONTRIBUTING.md for details.

@github-actions github-actions bot added the needs:compliance This means the issue will auto-close after 2 hours. label Mar 16, 2026
@github-actions
Copy link
Contributor

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

I found a highly relevant duplicate PR:

Potential Duplicate:

This PR appears to be addressing the exact same feature — dynamic model discovery for local providers including LM Studio and llama.cpp, which are the core use cases mentioned in PR #17688.

Related (but different scope):

You should investigate PR #17670 to determine if it's already addressing this functionality or if there's overlap in approach.

@hmblair hmblair changed the title Add local server provider with auto model discovery feat(opencode): add local server provider with auto model discovery Mar 16, 2026
@github-actions github-actions bot removed needs:compliance This means the issue will auto-close after 2 hours. needs:title labels Mar 16, 2026
@github-actions
Copy link
Contributor

Thanks for updating your PR! It now meets our contributing guidelines. 👍

…local provider tests

The CUSTOM_LOADERS loop skipped providers not registered in models.dev,
which prevented the local provider from ever being invoked. Create a
stub Info as a fallback so custom loaders can bootstrap themselves.

Adds three tests for the local provider: successful auto-discovery,
unreachable endpoint, and missing baseURL.
@github-actions github-actions bot added the needs:compliance This means the issue will auto-close after 2 hours. label Mar 17, 2026
@github-actions
Copy link
Contributor

This PR doesn't fully meet our contributing guidelines and PR template.

What needs to be fixed:

  • PR description is missing required template sections. Please use the PR template.

Please edit this PR description to address the above within 2 hours, or it will be automatically closed.

If you believe this was flagged incorrectly, please let a maintainer know.

@github-actions
Copy link
Contributor

This pull request has been automatically closed because it was not updated to meet our contributing guidelines within the 2-hour window.

Feel free to open a new pull request that follows our guidelines.

@github-actions github-actions bot removed the needs:compliance This means the issue will auto-close after 2 hours. label Mar 17, 2026
@github-actions github-actions bot closed this Mar 17, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Auto-discover models from OpenAI-compatible provider endpoints

1 participant