Skip to content

[AIT-667] spec/ait: extend error handling for turn operations and stream failures - #449

Merged
JoaoDiasAbly merged 1 commit into
ai-transport-featuresfrom
AIT-667/server-transport-error-handling
Apr 21, 2026
Merged

[AIT-667] spec/ait: extend error handling for turn operations and stream failures#449
JoaoDiasAbly merged 1 commit into
ai-transport-featuresfrom
AIT-667/server-transport-error-handling

Conversation

@JoaoDiasAbly

@JoaoDiasAblyJoaoDiasAbly commented Apr 17, 2026

Copy link
Copy Markdown
Contributor

Summary

Fixes three inconsistencies in server transport error handling identified in the PR #18 review and captured in AIT-667:

  1. addMessages() / addEvents() now call the per-turn onError on publish failure (parity with start() and end()).
  2. end() publish-failure behaviour is made explicit for parity with start().
  3. streamResponse() surfaces the caught error via StreamResult.error (preserving the original type) and via onError (wrapped as Ably.ErrorInfo).

It also records the deliberate decision on client-side error propagation.

New/changed spec points

Spec pointChange
AIT-ST5c (new)Publish failures in addMessages() / addEvents() must invoke onError and re-throw.
AIT-ST6b3 (refined)streamResponse() must not throw on stream errors; StreamResult.error must carry the original caught error; onError must be invoked with a wrapped Ably.ErrorInfo.
AIT-ST6b4 (new)Error details must not automatically propagate to the client; servers opt in via onMessage / application events. Rationale: avoid leaking internals and imposing a protocol contract on all codecs.
AIT-ST7b (new)end() publish failure must invoke onError and re-throw.

Error codes

  • TurnLifecycleError (104003) — description broadened to cover all turn publish failures (lifecycle event, message, or event).
  • StreamError (104008) — new code for source event stream failures during piping (e.g. LLM provider rate limit, model error).

Related

  • Companion implementation PR in ably-ai-transport-js to follow, on branch fix/AIT-667.

Test plan

  • Review reads cleanly as a spec addition (no behavioural contradictions with existing AIT-ST spec points)
  • Error code table entries align with the canonical definitions in ably-common/protocol/errors.json

🤖 Generated with Claude Code

@JoaoDiasAbly
JoaoDiasAblyforce-pushed the AIT-667/server-transport-error-handling branch from 45b6c44 to 4cce4fcCompareApril 21, 2026 16:46
Fixes inconsistencies in server transport error handling:
- addMessages() and addEvents() must reject with an Ably.ErrorInfo
(code TurnLifecycleError) on publish failure, wrapping the underlying
error as cause. The per-turn onError callback is NOT invoked — per
the project's single-delivery-channel rule, awaited methods surface
errors via promise rejection only (new AIT-ST5c).
- end() publish failure gets the same explicit treatment (new AIT-ST7b).
- streamResponse() stream errors preserve the original Error in
StreamResult.error and invoke onError with a wrapped Ably.ErrorInfo,
allowing server-side callers to distinguish provider errors such as
rate limits while giving observability a standardised type (refined
AIT-ST6b3). onError is the single ErrorInfo delivery path for
streamResponse since the method does not throw.
Also documents the deliberate decision that error details do NOT
propagate automatically to the client transport (new AIT-ST6b4):
server implementations forward details explicitly (e.g. via onMessage)
to avoid leaking internals and to avoid imposing a protocol contract
on all codecs.
Broadens the TurnLifecycleError (104003) description to cover all
turn publish failures, not just lifecycle events. Adds new error code
StreamError (104008) for source stream failures.
Refs: AIT-667
Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
@JoaoDiasAbly
JoaoDiasAblyforce-pushed the AIT-667/server-transport-error-handling branch from 4cce4fc to a14781dCompareApril 21, 2026 16:59
@JoaoDiasAbly
JoaoDiasAbly merged commit 3b611de into ai-transport-featuresApr 21, 2026
2 checks passed
@JoaoDiasAbly
JoaoDiasAbly deleted the AIT-667/server-transport-error-handling branch April 21, 2026 17:06
Sign up for freeto join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Development

Successfully merging this pull request may close these issues.

2 participants

@JoaoDiasAbly@zknill