Repository navigation
Description
Description
Custom providers/models that reference a documented @opencode/ai/providers/* package which is not part of the bundled package registry fail at model initialization:
Cannot initialize <provider>/<model>: Cannot find package '@opencode/ai' imported from B:\~BUN\root\chunk-x66j8jdp.js
Affected (100% reproducible on v2.0.24, Windows): @opencode/ai/providers/anthropic-compatible, @opencode/ai/providers/openai-compatible/responses, @opencode/ai/providers/openai-compatible-responses.
Not affected: @opencode/ai/providers/anthropic, @opencode/ai/providers/openai, @opencode/ai/providers/openai-compatible.
The modules exist in the npm package @opencode/[email protected] and their code is present in the compiled binary, so this looks like a resolution gap in the bundled registry used by Provider.loadPackage, not a missing package.
Plugins
none
OpenCode version
2.0.24
Steps to reproduce
- In
opencode.json, configure a custom provider (a model-level"package"override reproduces identically):
{
"providers": {
"acme": {
"package": "@opencode/ai/providers/anthropic-compatible",
"settings": {
"baseURL": "https://gateway.example.com/anthropic/v1",
"apiKey": "{env:ACME_KEY}"
},
"models": {
"anthropic/claude-sonnet-4.5": { "name": "Claude" }
}
}
}
}- Run
opencode reload. - Run
opencode run --model "acme/anthropic/claude-sonnet-4.5" "hello".
Screenshot and/or share link
N/A (CLI reproduction)
Operating System
Windows 10 (10.0.19045), x86_64
Terminal
Git Bash (MINGW64), TERM=xterm-256color
Additional context
From the compiled bundle, Provider.loadPackage first checks a static package-to-chunk map, then falls back:
let s = ED.get(i);
if (s) return importPackage(i, i, s);
let a = (() => {
if (i.startsWith("file://") || i.startsWith("@opencode/ai/")) return i; // bare specifier
try { return import.meta.resolve(i) } catch { return; }
})();
if (a) return importPackage(i, a); // import("@opencode/ai/...") fails in the compiled binary
// npm-install fallback below is unreachable for @opencode/ai/* because of the early return- The static map has 52 entries and includes
anthropic,openai,openai/chat,openai/responses,openai-compatible, but notanthropic-compatibleoropenai-compatible/responses. - Other code in the same bundle explicitly references
@opencode/ai/providers/anthropic-compatible(native-route check and credential mapping), so the registry appears to be missing entries. - Placing
@opencode/aiin the working directory or next to the executable does not help. Importing the module through afile://URL loads it, but its own bare dependencies then fail, so only the bundled path works.
Possible fixes: add the missing subpaths to the bundled registry, or remove the @opencode/ai/ early-return so the npm install fallback can run. In dev/source runs the same config resolves normally, which is likely why this only shows up in release builds.
Activity
opencode-agent commentedon Oct 8, 2026
Thanks for the detailed report! I could reproduce this on 2.0.24, and on Linux too, so it isn't specific to Windows.
With a custom provider whose
packageis@opencode/ai/providers/anthropic-compatible,@opencode/ai/providers/openai-compatible/responsesor@opencode/ai/providers/openai-compatible-responses,opencode run --model acme/m1 hellofails withCannot initialize acme/m1: Cannot find package '@opencode/ai' imported from /$bunfs/root/chunk-….js. With@opencode/ai/providers/openai-compatibleor@opencode/ai/providers/anthropic, the same config loads fine.It still happens with a binary built from the latest
v2commit (3b684acd8d). Your diagnosis matches the code: these three packages are missing from the built-in package list that release builds use.Related:
openai-compatible/responses. Its open PR fix(core): register compatible Responses provider #49808 adds only that entry, notanthropic-compatible.rekram1-node commentedon Oct 8, 2026
dumb bug... apologies