Skip to content

feat(cli): expose provider status and retry delay in ACP errors - #65564

Open
angelnereira wants to merge 4 commits into
anomalyco:devfrom
angelnereira:contrib-acp
Open

angelnereira wants to merge 4 commits into
anomalyco:devfrom
angelnereira:contrib-acp

Conversation

@angelnereira

@angelnereira angelnereira commented Nov 22, 2026 •

Copy link
Copy Markdown

Issue for this PR

Closes #65520

Type of change

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

What does this PR do?

ACP terminal errors dropped the provider status and retryAfterMs even though SessionError.Error carries them, so clients could not tell a rate limit from a generic failure. This widens executionError to SessionError.Error and copies status/retryAfterMs into the JSON-RPC data as validated optional fields. Provider bodies and stack traces are not forwarded.

How did you verify your code works?

A focused test in packages/cli/test/acp/error.test.ts covers execution.failed, step.failed, and a negative control. It fails before the fix (data missing status/retryAfterMs) and passes after. ACP suite: 115 pass, 0 fail.

Screenshots / recordings

Not a UI change.

Checklist

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

Added by the opencode bot (AI-generated).

Related: #50743

Public API: adds optional status and retryAfterMs to ACP prompt-failure JSON-RPC error data (backwards compatible)

@github-actions github-actions Bot added the needs:compliance This means the issue will auto-close after 2 hours. label Nov 22, 2026

@opencodejr opencodejr Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This works as described. I ran the new test against the base, where it fails because the error data lacks status and retryAfterMs. With this change it passes, and so does the rest of the ACP suite (bun test test/acp, 115/0). tsc -b in packages/cli is clean. Widening executionError to SessionError.Error matches what session.execution.failed already declares, and the new checks on ServiceFailureError are the same ones SessionError.Error already applies, so they can't reject a value that reaches ACP.

Public API: the JSON-RPC error data from an ACP session/prompt that ends in a provider failure can now also include status (an HTTP status number) and retryAfterMs (milliseconds to wait before retrying). Both fields are new and optional, so this is backwards compatible: existing clients that read only service and errorName are unaffected.

One thing to fix: please remove docs/kaizen/pr-drafts/feat-acp-error-status.md (see the inline comment).

Related: #50743

@@ -0,0 +1,17 @@
# feat(cli): expose provider status and retry delay in ACP errors

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This file is a copy of the PR description, and it looks like a local working note rather than repository docs. Please drop it from the change.

@opencodejr opencodejr Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The stray docs file is gone, which was my only open point. The code is unchanged from the version I checked before, so those results still apply: the new test fails on the base and passes with this change, the ACP suite passes, and tsc -b in packages/cli is clean. No new concerns.

Public API: the JSON-RPC error data from an ACP prompt that ends in a provider failure can now also include status (an HTTP status number) and retryAfterMs (milliseconds to wait before retrying). Both fields are new and optional, so existing clients are unaffected.

@github-actions github-actions Bot removed the needs:compliance This means the issue will auto-close after 2 hours. label Nov 22, 2026
@github-actions

Copy link
Copy Markdown
Contributor

Thanks for updating your PR! It now meets our contributing guidelines. 👍

@chirag127

Copy link
Copy Markdown
Contributor

Thanks for covering #65520. At 3634867, the wire test already covers execution/step failures with 429/60000 and omission when both fields are absent.

A small test-only addition could protect the remaining edges:

  • status: 503 without retryAfterMs, and retryAfterMs: 0 without status: assert exact data so each field works independently and zero survives.
  • Add a synthetic response.body sentinel to the provider failure used by both routes, then assert exact RPC data. The current toMatchObject checks allow unexpected extra properties.
  • The existing unknown-exception fixture could also carry numeric/response properties and assert it still exposes only generic error data.

The implementation already uses defined-value checks and explicit field copies. These are non-blocking regression suggestions; I reviewed the source without running this PR head.

@angelnereira

Copy link
Copy Markdown
Author

Thanks for the review suggestions. Added a focused test covering the exact edges you mentioned: status 503 without retryAfterMs, retryAfterMs 0 without status (zero survives), a response.body sentinel that stays out of the RPC data on both routes, and an unknown-exception fixture with extra numeric/response properties that still yields only generic error data. All assertions are exact (toEqual). Test file only, no production changes. bun test 5 pass/0 fail, bun run check 36/36.

@opencodejr opencodejr Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The new commit only adds a test, and the source is unchanged, so my earlier checks still apply: the change works, the ACP tests pass and tsc -b in packages/cli is clean. The public API impact is the same as before: two new optional fields in the error data, backwards compatible.

One request: please drop the new "acp error field isolation" test (see the inline comment). It is large for a 9-line change and adds little beyond the first test.

Comment thread packages/cli/test/acp/error.test.ts Outdated
})
})

describe("acp error field isolation", () => {

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please drop this second test so the change stays minimal. It starts a session for each case, and the case at the end (fromUnknown / toRequestError) covers code this PR doesn't touch. The other cases repeat what the first test already shows. Skipping fields that aren't set is the plain === undefined check in the code, and response.body can't leak because only named fields are copied. The test above already covers both failure paths and the case with neither field set.

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done: dropped the redundant 'acp error field isolation' test. The original test still covers both execution/step failure paths, the no-fields case, status + retryAfterMs, and zero survives via the defined-value checks; no production code touched. Test file only (55 lines removed): 4 pass / 0 fail, bun run check 36/36. Keeping the change minimal as requested.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks, confirmed. b864b35a2 removes only that test, and the change is now the same as the version I checked before, where the remaining test fails on the base and passes with this change. Nothing else from me on this thread.

@angelnereira

Copy link
Copy Markdown
Author

Thanks again for the suggestions. After review, we dropped the extra isolation test to keep the change minimal: the existing wire test already covers both failure paths and the no-fields case, and the implementation uses defined-value checks with only named fields copied (so response.body cannot leak). Zero retryAfterMs is still exercised by the code path. No production changes. Thanks for the careful review.

@opencodejr opencodejr Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Both earlier points are addressed: the draft docs file and the extra test are gone. The code is the same as the version I checked before, and the remaining test passes. No further concerns. The public API impact is unchanged: two new optional fields, status and retryAfterMs, in the ACP error data, backwards compatible.

This branch has not been deployed

No deployments
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: terminal errors omit V2 provider status and retry delay

2 participants