Skip to content

Session error path drops cause and stack from ProviderInitError, hiding root cause #24430

@NathanDrake2406

Description

@NathanDrake2406

Description

When Provider.resolveSDK throws InitError({providerID}, {cause: e}) (packages/opencode/src/provider/provider.ts:1522), the session pipeline catches it and re-emits via new NamedError.Unknown({message: err.message}).toObject(). err.cause and stack are discarded.

Consumers (e.g. cli/cmd/github.ts:986) only see:

Agent error: { name: "UnknownError", data: { message: "ProviderInitError" } }

This makes CI failures undebuggable. The real failure (NPM install error, missing peer dep, network failure, etc.) lives on err.cause and is silently dropped.

Expected: preserve the original named error (name: "ProviderInitError") and pass cause chain through to the consumer, e.g.

new NamedError.Unknown({ message: err.message }, { cause: err.cause })

and serialize cause chain in toObject(). Or stop re-wrapping ProviderInitError as UnknownError at the session boundary.

OpenCode version

1.14.25 (also reproduces on 1.14.22)

Steps to reproduce

  1. Trigger any failure inside resolveSDK — easiest path: cloudflare-ai-gateway/openai/gpt-5.4 on a fresh CI runner (see loadOptions(dir) in Npm.add reify path fails on CI runners → silent ProviderInitError for dynamic providers #24431)
  2. Observe CI log shows only UnknownError: ProviderInitError — the underlying InstallFailedError and its cause are gone.

Operating System

Linux (GitHub Actions ubuntu-latest), macOS 25.4

Impact

Every cf-ai-gateway repo that hit the 1.14.x install regression saw an unactionable error. Multiple Cloudflare repos (workers-sdk, workerd, kumo, containers, vinext) pinned older opencode versions without an upstream issue because the symptom was not diagnosable.

Metadata

Metadata

Assignees

Labels

coreAnything pertaining to core functionality of the application (opencode server stuff)

Type

No type
No fields configured for issues without a type.

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions