Skip to content

providers: config-declared providers never materialize into registry (v2.0.15) #51285

Closed as duplicate

Description

@Dqz00116

Description

Summary

Providers declared in the providers section of opencode.jsonc (with package: "aisdk:@ai-sdk/openai-compatible" and settings containing baseURL/apiKey) are never materialized into the provider registry in v2.0.15. They do not appear in context.provider.list(), nor in the plugin transform editor view (editor.get()/editor.list()), so custom providers configured purely via config are silently invisible and unusable.

Environment

  • opencode version: 2.0.15
  • OS: Windows_NT 10.0.19045 (win32 x64)
  • Terminal: TERM=xterm-256color
  • Shell: C:\WINDOWS\system32\cmd.exe
  • Install/channel: latest (npm @opencode/cli@2.0.15, also reproduced with side-by-side npm i --prefix install)
  • Active plugins: one local server plugin under ~/.config/opencode/plugin/ (registers provider models via context.provider.transform)

Reproduction

  1. Create ~/.config/opencode/opencode.jsonc with a custom provider:

    {
      "$schema": "https://opencode.ai/config.json",
      "providers": {
        "mygateway": {
          "package": "aisdk:@ai-sdk/openai-compatible",
          "name": "MyGateway",
          "settings": {
            "baseURL": "http://localhost:8080/v1",
            "apiKey": "<key>"
          },
          "models": { "my-model": {} }
        }
      }
    }
  2. Run opencode models (or opencode run -m mygateway/my-model "hi").

  3. In a server plugin, call await context.provider.list() and, inside context.provider.transform(editor => ...), call editor.get("mygateway").

Expected Behavior

Per the SDK's own documentation, the registry view should include source definitions: ProviderRecord is documented as "Provider metadata and immutable source definitions, including inactive providers" (@opencode/plugin provider.d.ts). A providers entry in config is exactly such a source definition — and the config schema intentionally has no activation key, implying the server should materialize it without any user-side activation step. So mygateway should appear in both provider.list() and the transform editor view, with settings.apiKey/settings.baseURL readable.

Actual Behavior

  • context.provider.list() returns only the built-in opencode provider; mygateway is absent.
  • Inside transform, editor.get("mygateway") returns undefined on every invocation (verified across hundreds of transform passes, including the very first one with the config in place).
  • opencode models lists only opencode/* models.
  • opencode run -m mygateway/my-model fails with ModelUnavailableError: Model unavailable: mygateway/my-model.
  • No error or warning is logged about the providers section — it parses cleanly (opencode debug config shows it normalized under providers) but is silently never registered.

Additional Context

  • This makes the documented v1 → v2 migration path (provider → providers, npm → package with aisdk: prefix, options → settings) incomplete: the config normalizes fine but the provider never becomes usable.
  • Workaround we are using: a server plugin that re-declares the provider itself via editor.add({ info: {...}, models: [...] }) inside context.provider.transform, reading baseURL/apiKey from environment variables because the config settings are unreachable. This works, but defeats the purpose of declaring the provider in config.
  • One path we did NOT test: calling await context.provider.reload() before transform — its behavior is undocumented. If reload() is supposed to re-materialize config-defined providers, that would be an acceptable fix; happy to test.
  • Possibly related: disabled_providers: ["opencode"] in the same config also appears to have no effect (the opencode provider still lists its models), suggesting config-driven provider state in general may not be wired to the registry in this version.

Plugins

  • opencode-agents-monitor@0.2.0-beta.0 (npm, TUI plugin via cli.json plugins) - custom-models (local server plugin at ~/.config/opencode/plugin/custom-models.ts) — re-registers the custom provider via context.provider.transform + editor.add; this is the workaround, not the cause

OpenCode version

2.0.15

Steps to reproduce

  1. Add a custom provider to ~/.config/opencode/opencode.jsonc:
    "providers": {
    "mygateway": {
    "package": "aisdk:@ai-sdk/openai-compatible",
    "name": "MyGateway",
    "settings": {
    "baseURL": "http://localhost:8080/v1",
    "apiKey": ""
    },
    "models": { "my-model": {} }
    }
    }
  2. Run opencode models — only opencode/* models are listed; mygateway is absent.
  3. Run opencode run -m mygateway/my-model "hi" — fails with ModelUnavailableError: Model unavailable: mygateway/my-model.
  4. (Optional, confirms registry-level absence) In a server plugin, call await context.provider.list() — returns only the built-in opencode provider; inside context.provider.transform(editor => ...), editor.get("mygateway") returns undefined on every invocation.

Screenshot and/or share link

N/A — no screenshot. Key log evidence: zero error/warning lines about the providers section (it parses and normalizes cleanly per opencode debug config, but is silently never registered). No session share link — reproduction is config-only and does not require a session.

Operating System

Windows 10 (build 19045) — win32 x64

Terminal

PowerShell 7 (pwsh), TERM=xterm-256color

Activity

  1. github-actions commented on Sep 25, 2026

    @github-actions
    Contributor

    This issue might be a duplicate of existing issues. Please check:

    • #42856: V2 user-defined provider configurations are absent from the provider and model catalogs, causing Model unavailable.
    • #51252: V2 ignores entries in the native providers configuration block during provider discovery.
  2. wangjianjq commented on Oct 1, 2026

    @wangjianjq

    Still reproduces on v2.0.21 stable (Windows 11 10.0.26300, x64) — so this is not fixed as of the latest latest-channel CLI, and it is not limited to 2.0.15.

    Version matrix (all fail identically)

    Runtime Result
    opencode CLI 2.0.15 ModelUnavailableError
    opencode CLI 2.0.20 ModelUnavailableError
    opencode CLI 2.0.21 ModelUnavailableError
    2.0.21 desktop app (opencode-cli.exe serve --service) same
    opencode-ai@1.18.34 (npm) different failure: UnknownError: Unexpected server error

    What was tested (clean directory, no project config, no plugins)

    Both config syntaxes fail to register, silently, with no skipped malformed normalization warnings (so this appears distinct from #49912's capabilities/tools skip — our config normalizes cleanly and only emits omitted unsupported legacy setting WARNs for reasoning):

    v1 syntax (real gateway replaced with a placeholder endpoint):

    {
      "$schema": "https://opencode.ai/config.json",
      "provider": {
        "mygateway": {
          "npm": "@ai-sdk/openai-compatible",
          "name": "MyGateway",
          "options": {
            "baseURL": "https://api.example-gateway.ai/v1",
            "apiKey": "{env:MY_API_KEY}"
          },
          "models": {
            "my-model": { "name": "My Model", "limit": { "context": 1000000, "output": 128000 } }
          }
        }
      }
    }

    v2 syntax (same failure):

    {
      "$schema": "https://opencode.ai/config.json",
      "providers": {
        "mygateway": {
          "name": "MyGateway",
          "env": ["MY_API_KEY"],
          "package": "@opencode/ai/providers/openai-compatible",
          "settings": { "baseURL": "https://api.example-gateway.ai/v1" },
          "models": { "my-model": { "name": "My Model" } }
        }
      }
    }

    Observations

    • opencode models lists only built-in opencode/* models (the Zen catalog); custom providers absent.
    • opencode run -m mygateway/my-model "hi" → Error: Model unavailable: mygateway/my-model.
    • With no -m, the configured default custom model is silently ignored and the session falls back to a built-in opencode/* model — easy to miss and confusing.
    • Config is parsed and normalized (the server logs configuration normalization diagnostic entries iterating our models), yet nothing registers. Matches the reporter's finding: parses cleanly, never materializes.
    • Not auth/env-related: verified MY_API_KEY is present in the server process env, and replacing {env:MY_API_KEY} with a literal key changes nothing.
    • Reproduced with --standalone (private server) and against the background service; config was validated with a JSONC parser between attempts (no BOM, no syntax errors).

    The v1-style block above is the same shape that worked before we upgraded to the 2.0.x line, and per this issue + #42856 + #51031 it now silently no-ops across the whole stable range. The plugin context.provider.transform + editor.add() workaround mentioned here works, but config-declared providers (and the v1→v2 migration path) remain unusable.

    Happy to test a fix build.

  3. neriousy commented on Oct 20, 2026

    @neriousy
    Member

    Thanks for the report. We're tracking this same problem with config-declared providers missing from the model catalog in #42856, so I'm closing this as a duplicate. Please follow that issue for updates.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions