Repository navigation
feat(cli): expose provider status and retry delay in ACP errors - #65564
angelnereira wants to merge 4 commits into
Conversation
There was a problem hiding this comment.
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 | |||
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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.
|
Thanks for updating your PR! It now meets our contributing guidelines. 👍 |
|
Thanks for covering #65520. At A small test-only addition could protect the remaining edges:
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. |
|
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. |
There was a problem hiding this comment.
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.
| }) | ||
| }) | ||
|
|
||
| describe("acp error field isolation", () => { |
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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.
|
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. |
There was a problem hiding this comment.
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.
Issue for this PR
Closes #65520
Type of change
What does this PR do?
ACP terminal errors dropped the provider
statusandretryAfterMseven thoughSessionError.Errorcarries them, so clients could not tell a rate limit from a generic failure. This widensexecutionErrortoSessionError.Errorand copiesstatus/retryAfterMsinto the JSON-RPCdataas 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.tscoversexecution.failed,step.failed, and a negative control. It fails before the fix (datamissingstatus/retryAfterMs) and passes after. ACP suite: 115 pass, 0 fail.Screenshots / recordings
Not a UI change.
Checklist
Added by the opencode bot (AI-generated).
Related: #50743
Public API: adds optional
statusandretryAfterMsto ACP prompt-failure JSON-RPC error data (backwards compatible)