anomalyco / anomalyco/opencode
ACP: map structured provider HTTP 401/403 errors to AuthRequiredError
@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
- Configure an OpenAI-compatible provider with an invalid API key.
- Start
opencode acpand initialize an ACP session. - Send a prompt that reaches the provider.
- Observe the provider's structured 401 error becoming generic
-32603rather than an ACP authentication-required error.
Operating System
Linux x86_64
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Assessment
This issue has not been assessed yet.