Skip to content

fix(acp): pass provider status and response headers of API errors to clients - #52861

Closed
benediktkraus wants to merge 1 commit into
anomalyco:devfrom
benediktkraus:bka-acp-fehlerstatus
Closed

benediktkraus wants to merge 1 commit into
anomalyco:devfrom
benediktkraus:bka-acp-fehlerstatus

Conversation

@benediktkraus

Copy link
Copy Markdown

Issue for this PR

Closes #52860

Type of change

  • Bug fix
  • New feature
  • Refactor / code improvement
  • Documentation

What does this PR do?

A prompt that fails with an APIError reaches ACP clients as -32603 with only {service, errorName}. The APIError already has the HTTP status, the retryable flag and the provider's response headers, but promptResponse drops them, so a client cannot recognise a rate limit or read retry-after / x-ratelimit-reset.

ServiceFailureError gets three optional fields (statusCode, isRetryable, responseHeaders), toRequestError puts them into the error data when set, and promptResponse fills them from APIError.data only. Every other error is mapped as before. The headers are the ones opencode already stores on the message error.

How did you verify your code works?

  • bun test test/acp/ in packages/opencode: 140 pass. One new test for an APIError with status 429 and headers; the existing APIError test now also expects isRetryable.
  • bun run typecheck in packages/opencode is clean.
  • Built the CLI with script/build.ts and ran opencode acp through acpx against an OpenRouter free model with the daily limit used up: the error data now has "statusCode":429, "isRetryable":true and the response headers including x-ratelimit-reset.

Screenshots / recordings

Not a UI change.

Checklist

  • I have tested my changes locally
  • I have not included unrelated changes in this PR

…clients

A failed prompt reached ACP clients as a generic -32603 with only
{service, errorName}. For an APIError, opencode already knows the HTTP
status, whether the provider marks it retryable, and the response headers
(retry-after, x-ratelimit-reset, ...). Without them a client cannot tell a
rate limit from any other provider failure, nor when it may try again.

ServiceFailureError now carries statusCode, isRetryable and
responseHeaders, filled from APIError.data only; other errors are mapped
as before.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Claude-Session: https://claude.ai/code/session_01MskzQg6anPuQU4pctoFQgW
@github-actions

github-actions Bot commented Oct 2, 2026

Copy link
Copy Markdown
Contributor

The following comment was made by an LLM, it may be inaccurate:

@thdxr

thdxr commented Oct 10, 2026

Copy link
Copy Markdown
Member

This branch has been upgraded to V2. We're no longer taking PRs for V1. If you think this is still relevant, please port it over and open it for V2.

— from 𝕺𝖕𝖊𝖓𝕮𝖔𝖉𝖊

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

ACP: provider status and rate-limit headers of API errors are dropped

2 participants