GeezerVisonThe World Wide Web, restored to 800 pixels of glory. | |||||||||||||
| Home|About|Gaming cabinet|Archives|How it works|Starter sites | |||||||||||||
GeezerVison is showing github.com — feat(provider): add dynamic model discovery for custom providers by Gr33ndev · Pull Request #42660 · anomalyco/opencode Conversation
|
|
The following comment was made by an LLM, it may be inaccurate: Based on my search, I found several related PRs that address similar functionality: Potential Related PRs:
These PRs seem to be addressing the same problem space of discovering models from providers. You may want to check if #32731 is a closed/incomplete predecessor or if these are complementary features addressing different provider types. |
Sorry, something went wrong.
There was an error while loading. Please reload this page.
Scope: dynamic model discovery for custom OpenAI-compatible providers: new server-side
|
Sorry, something went wrong.
There was an error while loading. Please reload this page.
|
Perfect, that's just what I needed! |
Sorry, something went wrong.
There was an error while loading. Please reload this page.
|
+1 |
Sorry, something went wrong.
There was an error while loading. Please reload this page.
There was an error while loading. Please reload this page.
|
really needed this, merge it asap |
Sorry, something went wrong.
There was an error while loading. Please reload this page.
|
This is really what I'm lacking of |
Sorry, something went wrong.
There was an error while loading. Please reload this page.
|
Would be awesome if this is included in the new release! |
Sorry, something went wrong.
There was an error while loading. Please reload this page.
|
This is exactly where opencide still lacks behind. Absolutely needed! |
Sorry, something went wrong.
There was an error while loading. Please reload this page.
|
We really need this! |
Sorry, something went wrong.
There was an error while loading. Please reload this page.
…viders
A configured provider can opt in (discover: true, or the v1 config's
discoverModels: true) to have opencode call GET {baseURL}/models and
add whatever the endpoint reports to the catalog, instead of
requiring every model to be hand-listed -- useful for LM Studio,
vLLM, llama.cpp/llama-swap, or any generic OpenAI-compatible
self-hosted endpoint.
Ported from upstream anomalyco#6231 (247 reactions/57
comments -- the second-highest reaction count found across a full
survey of this repo's open issues). Three substantial PRs sat open
and unmerged for 3+ months despite that reaction count. PR anomalyco#32731 (8
files, tightly scoped) is the primary source: this fork reuses its
discoverModels field name, which limit fields to read from the
response, the discovered-model shape, and the "configured/models.dev
wins" merge rule. Deliberately changed from anomalyco#32731: discovery is
opt-in per provider here, not automatic for every provider with a
baseURL -- always-on would fire a startup network request at every
existing custom provider. Unknown limits are left at 0 rather than
anomalyco#32731's guessed 128k default. PR anomalyco#42660's URL-with-existing-path
handling was reused, rewritten with this repo's own HttpClient/Schema
idioms instead of raw fetch in a try/catch; its UI and endpoint
weren't ported. PR anomalyco#27554 (100+ files) had nothing usable beyond
confirming scope overlap. New, since none of the three PRs target it:
a v2 Catalog.Service plugin (this repo didn't have a plugin/catalog
system when those PRs were written).
Runs in both of this repo's provider surfaces: the legacy provider
service (inline before the filter pass, what the TUI model picker
reads) and a new v2 Catalog plugin (packages/core/src/config/plugin/
provider-discovery.ts, once at startup then hourly, same schedule as
the models.dev refresh).
Known gaps: the legacy provider service has no periodic refresh (a
newly-loaded local model appears only after restart/reload); stale
models aren't hidden; discovered capabilities are guesses (no
vision/reasoning detection); only the standard OpenAI models response
shape is understood, not Ollama's native /api/tags; no settings UI or
HTTP endpoint; legacy auth only checks a stored credential or
options.apiKey, not plugin OAuth loaders.
New packages/core/test/provider-discovery.test.ts + config/
provider-discovery.test.ts (unit-level) and packages/opencode/test/
provider/discovery.test.ts (against a real local Bun.serve server,
not a mock). Verified against this fork's current dev, not just the
agent's own stale worktree base: bun typecheck clean across all 30
packages; packages/core 1187 pass (only the pre-existing pty flake);
packages/opencode 3617 pass, only the 4 pre-existing cf-ai-gateway
failures. bun run generate from packages/client correctly produced
no changes -- this is a config-only field, not a Protocol/HttpApi
schema change.
Co-Authored-By: Claude Sonnet 5 <[email protected]>
|
@Enough1122 Sorry it took me so long to get to these changes, and thanks for the review! Addressed in the latest push:
While in there I fixed two more things:
Added tests for concurrency, failure isolation, the whitelist and the config |
Sorry, something went wrong.
There was an error while loading. Please reload this page.
|
Hi @Hona! |
Sorry, something went wrong.
There was an error while loading. Please reload this page.
…/models opencode builds its picker from models.dev plus the static `models` map in opencode.json. It does not call a custom provider's /v1/models — discovery is hardcoded to Ollama, LM Studio and vLLM at their default ports. A provider written with only npm + baseURL shows up as "Provider not found" with an empty list. Verified on 1.18.3, where `opencode models archrouter` listed nothing at all; general discovery is still an open PR (anomalyco/opencode#42660), so there is nothing to wait for. So the static list is now the default and --variants becomes --no-models, which only exists to clean up an older install. The key is resolved from ARCHROUTER_KEY, then first-key.txt, then whatever /connect saved, and written into options.apiKey: auth is required by default, so /v1/models answers 401 without it — including the probe this command runs to fetch that list, which is why --variants died on every auth-on install with "router not answering". Models opencode cannot reach are still listed, with the measurements kept in modelCaps.js and opencodeConfig.js rather than hidden: muse-spark-*-contributor- free and jev-1.13-free answer only on /v1/responses and /v1/messages and 500 on the chat path, and ling-3.0-flash-fin-free (400) plus ling-3.1-flash-free (429) are reproducibly dead upstream, 3/3 attempts each on 2026-10-04. The other 7 answer 200 through /v1/chat/completions. 206 tests pass: test-p0 52, test-auth-store 6, test-setup-sh 40, test-uninstall 48, test-setup-flow 60. The suite carried a test whose name asserted the false premise above; it is inverted now, and two more cover the apiKey and the default shape. Not tested: WARP registration end to end (it burns real Cloudflare slots), and opencode's own picker — the catalog was confirmed through `opencode --pure models`, because a local plugin's dependency install deadlocks the plain CLI (anomalyco/opencode#47212, unrelated to this repo).
|
This branch has been upgraded to V2. We're no longer taking PRs for V1. If you think this is still relevant, please port it over and open it for V2. — from 𝕺𝖕𝖊𝖓𝕮𝖔𝖉𝖊 |
Sorry, something went wrong.
There was an error while loading. Please reload this page.
|
Thanks! I ported this to V2 in #57161. It adds discovered models to configured OpenAI-compatible providers (LiteLLM and other gateways), so let's continue there. |
Sorry, something went wrong.
There was an error while loading. Please reload this page.
There was an error while loading. Please reload this page.
Successfully merging this pull request may close these issues.
[FEATURE]: Dynamic model discovery for local OpenAI-compatible providers [FEATURE]: Auto-Detect and Sync Local/Remote Ollama Models [FEATURE]: Detect model(s) using the /v1/models route on custom provider [FEATURE]:LM Studio provider should auto-detect models via /v1/models API (similar to Continue extension) [FEATURE]: Auto-load available models from LiteLLM proxy withautoload option
There was an error while loading. Please reload this page.