fix(acp-server): surface provider errors on session/prompt - #3161
Open
jangjoe wants to merge 1 commit into
Open
Conversation
`session/prompt` used to silently resolve with `{stopReason: 'end_turn'}`
when the model provider returned a transport / status failure
(rate limit, overload, 5xx, connection loss, etc.). The engine already
classifies these as born-coded `Error2` instances with codes like
`provider.api_error` / `provider.overloaded` /
`provider.connection_error` / `context.overflow` and surfaces them
on `turn.ended{ reason: 'failed' }`, but the ACP layer only knew how to
map auth errors — every other failure was swallowed into `end_turn`
and clients had no way to tell the model service was unavailable.
Add `isProviderError()` in events-map.ts (sibling to `isAuthError()`)
and a third branch in both `AcpSession.onTurnEnded` and
`mapPromptLaunchError`: provider / context failures now reject with
`RequestError.internalError({ code, message }, "model provider
reported an error")`. The engine's full text rides in the JSON-RPC
`data` payload so clients can log it; the wire message stays generic
to keep provider-supplied PII out of every error toast. Auth failures
keep their existing `auth_required` mapping; content-filter failures
keep the legacy `refusal` mapping in `turnEndReasonToStopReason`.
The scripted provider helper gains `mockNextProviderError(code, message)`
so end-to-end tests can throw a coded provider error without going
through the network layer.
Resolve MoonshotAI#3107
🦋 Changeset detectedLatest commit: 428e850 The changes in this PR will be included in the next version bump. This PR includes changesets to release 1 package
Not sure what this means? Click here to learn what changesets are. Click here if you're a maintainer who wants to add another changeset to this PR |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Resolve #3107
session/promptused to silently resolve with{stopReason: 'end_turn'}when the model provider returned a transport / status failure
(rate limit, overload, 5xx, connection loss, etc.). The engine already
classifies these as born-coded
Error2instances with codes likeprovider.api_error/provider.overloaded/provider.connection_error/context.overflowand surfaces themon
turn.ended{ reason: 'failed' }, but the ACP layer only knew howto map auth errors — every other failure was swallowed into
end_turnand clients had no way to tell the model service was unavailable.
Change
Add
isProviderError()inpackages/acp-server/src/events-map.ts(sibling to
isAuthError()) and a third branch in bothAcpSession.onTurnEndedandmapPromptLaunchError: provider /context failures now reject with
RequestError.internalError({ code, message }, "model provider reported an error"). The engine's full text rides in the JSON-RPCdatapayload so clients can log it; the wire message stays genericto keep provider-supplied PII out of every error toast.
auth_requiredmapping.provider.filtered) keep the legacyrefusalmapping inturnEndReasonToStopReasonand fall throughto the fixed generic message at launch (where no turn exists yet to
attach a refusal to).
The scripted provider helper gains
mockNextProviderError(code, message)so end-to-end tests can throw a coded provider error without going
through the network layer.
Test plan
packages/acp-server/test/events-map.test.ts— new unit tests forisAuthError/isProviderError/turnEndReasonToStopReason,covering every code in each set plus the cross-set negatives
(
provider.filteredmust not matchisProviderError).packages/acp-server/test/e2e-turn.test.ts—mapPromptLaunchErrorunit tests for
provider.api_error/context.overflow/provider.filtered(legacy) and a scripted end-to-end test thatthrows a coded provider error mid-turn and asserts the prompt
rejects as
internalErrorcarrying the engine message indata.