Skip to content

ACP: map structured provider HTTP 401/403 errors to AuthRequiredError #48297

Closed

Description

@KayIter

Description

With OpenCode 1.18.30 in ACP mode, an OpenAI-compatible provider can return a structured APIError with data.statusCode 401 or 403. packages/opencode/src/acp/service.ts only maps ProviderAuthError to ACP AuthRequiredError, so this case is emitted as a generic JSON-RPC -32603 / service failure. ACP clients consequently cannot distinguish an expired or invalid credential from a backend failure.

Expected behavior: classify structured APIError.data.statusCode values 401 and 403 as AuthRequiredError. Please keep the check structured: message text and provider response bodies should not be parsed or forwarded, and 429/unknown errors should remain non-auth failures.

OpenCode version

1.18.30

Steps to reproduce

  1. Configure an OpenAI-compatible provider with an invalid API key.
  2. Start opencode acp and initialize an ACP session.
  3. Send a prompt that reaches the provider.
  4. Observe the provider's structured 401 error becoming generic -32603 rather than an ACP authentication-required error.

Operating System

Linux x86_64

Activity

  1. nexxeln commented on Oct 1, 2026

    @nexxeln
    Contributor

    hey! this should be fixed in v2 now 🙏 if you're still on 1.x, upgrading to v2 should sort it out. let us know if you still hit it after upgrading and we'll take another look!

  2. nexxeln commented on Oct 6, 2026

    @nexxeln
    Contributor

    Fixed on v2. Core classifies provider 401 and 403 responses as authentication failures, and the ACP agent returns ACP's auth_required error (-32000) for them, while rate limits stay internal errors. Please reopen if an invalid key still gives -32603 on v2.

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