From 9eb126e7b2fe3a539b653e9c846638ce15f32ee1 Mon Sep 17 00:00:00 2001 From: Mario Zechner Date: Thu, 7 May 2026 11:42:35 +0200 Subject: [PATCH] docs(ai): document interleaved stream events --- packages/ai/README.md | 2 ++ 1 file changed, 2 insertions(+) diff --git a/packages/ai/README.md b/packages/ai/README.md index 51b3ef53..df8136a4 100644 --- a/packages/ai/README.md +++ b/packages/ai/README.md @@ -383,6 +383,8 @@ All streaming events emitted during assistant message generation: | `done` | Stream complete | `reason`: Stop reason ("stop", "length", "toolUse"), `message`: Final assistant message | | `error` | Error occurred | `reason`: Error type ("error" or "aborted"), `error`: AssistantMessage with partial content | +Streaming events for different content blocks are not guaranteed to be contiguous. Providers may emit deltas for text, thinking, and tool calls in the same upstream chunk, and pi may surface corresponding events interleaved, for example `text_start`, `text_delta`, `toolcall_start`, `text_delta`, `toolcall_delta`. Consumers must use `contentIndex` to associate each delta/end event with its block and must not assume that a block's `*_start`/`*_delta`/`*_end` sequence is uninterrupted by events for other blocks. + ## Image Input Models with vision capabilities can process images. You can check if a model supports images via the `input` property. If you pass images to a non-vision model, they are silently ignored.