Skip to content

fix(acp-server): surface provider errors on session/prompt - #3161

Open
jangjoe wants to merge 1 commit into
MoonshotAI:mainfrom
jangjoe:fix/surface-provider-errors
Open

fix(acp-server): surface provider errors on session/prompt#3161
jangjoe wants to merge 1 commit into
MoonshotAI:mainfrom
jangjoe:fix/surface-provider-errors

Conversation

@jangjoe

@jangjoe jangjoe commented Aug 21, 2026

Copy link
Copy Markdown

Resolve #3107

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.

Change

Add isProviderError() in packages/acp-server/src/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 (provider.filtered) keep the legacy
    refusal mapping in turnEndReasonToStopReason and fall through
    to 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 for
    isAuthError / isProviderError / turnEndReasonToStopReason,
    covering every code in each set plus the cross-set negatives
    (provider.filtered must not match isProviderError).
  • packages/acp-server/test/e2e-turn.test.tsmapPromptLaunchError
    unit tests for provider.api_error / context.overflow /
    provider.filtered (legacy) and a scripted end-to-end test that
    throws a coded provider error mid-turn and asserts the prompt
    rejects as internalError carrying the engine message in data.

`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-bot

changeset-bot Bot commented Aug 21, 2026

Copy link
Copy Markdown

🦋 Changeset detected

Latest commit: 428e850

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 1 package
Name Type
@moonshot-ai/kimi-code Patch

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

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.

fix(acp-server): surface provider errors on session/prompt

1 participant