Skip to content

v0.5.0

Choose a tag to compare

@github-actions github-actions released this 24 Oct 17:36
· 22 commits to main since this release
89394e2

prism 0.5.0: an Anthropic stream that ends early is reported, not passed off as finished

BREAKING CHANGE: an Anthropic stream now always ends with exactly one StreamEndEvent, which reports FinishReason Error if anything went wrong, and its usage is null unless the final usage arrived. Before, a stream cut off before message_stop simply stopped, with no error and no end event; a provider error event was followed by no end event; a later stop could overwrite an earlier error with Stop; and a stream missing its final usage reported the start-of-message counters (the input, no output) as its total. If you treat the end event or its usage as a complete, billable call, check finish_reason and treat a null usage as unknown, not free.

What changed, matching the PHP reference (particle-academy/prism 0.135.0):

  • A stream that ends before Anthropic's message_stop (a dropped connection, a proxy cut) emits an incomplete_stream error, non-recoverable, then a StreamEndEvent with finish Error.
  • After a provider error event, the stream still ends with a StreamEndEvent, finish Error, and an unfinished text block is closed with its text. A later stop or final usage never turns Error back into Stop.
  • The StreamEndEvent usage is null when Anthropic never sent the final usage (output_tokens in message_delta), so a partial count is never reported as the total.
  • Tool input cut off mid-stream is discarded: it never becomes a completed, executable tool call.
  • ErrorEvent gains an optional recoverable flag.

Verified by a new cross-language streaming suite (prism-parity corpus 0.1.11, ten cases including a truncated tool call and keepalive/unknown events), generated from the published PHP reference and run against both ports. The event vocabulary still differs from the reference (no step events; tracked as G-125); the properties above hold in all three languages.