anomalyco / anomalyco/opencode

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

Open
#48,297 0 comments 0 reactions 1 assignee View on GitHub

@rekram1-node is already working on this.

Since Sep 10, 2026.

Dominant language
TypeScript
Stars
209k
Forks
27.5k
PR merge metrics
PR metrics pending

Description

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

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.