Repository navigation
Description
Description
1.14.x added loadOptions(dir) via @npmcli/config to the reify path in packages/opencode/src/npm/index.ts. It runs new Config({...}).load() against cwd: <cache>/packages/<pkg> before arborist.reify. On CI runners (GitHub Actions, ubuntu-latest), this throws and bubbles as InstallFailedError, which provider.ts:1522 re-wraps as InitError, which the session path strips to UnknownError: ProviderInitError (see #24430).
Scope: only affects models whose models.dev provider.npm is not in opencode's BUNDLED_PROVIDERS map. Bundled SDKs skip Npm.add entirely. For cloudflare-ai-gateway this is asymmetric:
| Upstream | models.dev npm |
path |
|---|---|---|
openai/* |
ai-gateway-provider |
dynamic Npm.add → hits loadOptions → fails |
anthropic/* |
@ai-sdk/anthropic |
bundled → no install → works |
google-ai-studio/* |
@ai-sdk/google |
bundled → works |
This is why anthropic/google on cf-ai-gateway works on 1.14.x while OpenAI is broken: same gateway, different install path.
Expected: Npm.add should not depend on @npmcli/config.load() succeeding for a fresh empty dir. Either skip loadOptions when no .npmrc / package.json exists yet, or catch and continue with npmOptions = {}.
OpenCode version
1.14.22, 1.14.25 (any 1.14.x). Pre-1.14 reify path (no loadOptions) is known-good.
Steps to reproduce
- Fresh ubuntu-latest runner
opencode_version: 1.14.25- Dynamic-SDK model, e.g.
cloudflare-ai-gateway/openai/gpt-5.4 - Set
CLOUDFLARE_ACCOUNT_ID,CLOUDFLARE_GATEWAY_ID,CLOUDFLARE_API_TOKEN - Send any prompt →
UnknownError: ProviderInitErrorwithin ~1s
Verified locally on 1.14.25:
cloudflare-ai-gateway/anthropic/claude-opus-4-7reaches AI Gateway (real auth error visible)cloudflare-ai-gateway/openai/gpt-5.4fails insideNpm.addreify, surfaces asUnknownError: ProviderInitError
Operating System
Linux (GitHub Actions ubuntu-latest), reproduced on macOS 25.4
Workaround in the wild
- workers-sdk pinned
1.4.6: ci: pin OpenCode for CI jobs cloudflare/workers-sdk#13624 - workerd, containers, kumo, workers-py pin
1.4.6/1.2.27for the same symptom - vinext PR: ci(bonk): bump opencode to 1.4.11 to unblock OAI through cf-ai-gateway cloudflare/vinext#903
Most CF repos running anthropic on cf-ai-gateway only hit this when something else triggers a non-bundled install. vinext is the only one running OAI through cf-ai-gateway, hence deterministic failure.
Bonus: stale-cache short-circuit
Npm.add at npm/index.ts:195:
if (yield* afs.existsSafe(dir)) {
return resolveEntryPoint(name, path.join(dir, "node_modules", name))
}If a prior reify left dir populated but node_modules/<pkg> missing (e.g. crash mid-install), Npm.add returns entrypoint: Option.none() forever. Fix: check node_modules/<pkg> exists, otherwise re-reify.
Activity
github-actions commentedon Apr 26, 2026
Thanks for updating the issue! It now includes clear reproduction steps, environment details, and specific version information. Everything looks good — the
needs:compliancelabel has been removed.