> ## Documentation Index
> Fetch the complete documentation index at: https://docs.blobhub.io/llms.txt
> Use this file to discover all available pages before exploring further.

# Streaming

> An answer drawn while it is written: partial messages, broadcast to followers and never stored.

Every language model call [`genai.chat`](https://docs.blobhub.io/blob-types/workflow/workflows/component-genai-chat) makes is streamed from
the vendor, on every dialect, and assembled into the same message a plain call returns. Streaming also keeps a long
answer from running into the vendor call's read timeout while the model is still writing.

While a call streams, the text so far can be drawn by whoever follows the session. Those pushes are **partial
messages**. A partial message is sent to the connections following the session, is never stored, and is never on the
[event stream](https://docs.blobhub.io/blob-types/workflow/workflows/session-events.md). When the answer is complete, the stored thread item or
object event replaces it.

```mermaid theme={null}
flowchart LR
  chat["Chat call, streamed"]
  follower["Connection following the session"]
  store["Thread item or object"]
  reader["Reader afterwards"]

  chat -->|"partial messages, about four a second"| follower
  chat -->|"the final message"| store
  store --> reader
```

## Partial messages

A partial message is a `partial` frame. It goes to each connection that follows the session with a matching listener
(see [Following partial messages](#following-partial-messages)), for as long as the call streams.

```json theme={null}
{"type": "partial", "alias": "conversation", "item_id": "01JF…", "seq": 7, "state": "open",
 "source": {"kind": "workflow", "user_id": "…", "execution_id": "…", "component_id": "…", "depth": 0},
 "blocks": [{"index": 0, "type": "reasoning", "delta": "…"}, {"index": 1, "type": "text", "delta": "…"}]}
```

| Field | Meaning |
| :- | :- |
| `alias` | The alias of the thread or object the answer is being written to. |
| `item_id` | The id of the item the answer will be stored as, so a reader replaces the partial message with that item. Left out when the answer goes to an object. |
| `seq` | The frame's number in this answer, counted from 1. |
| `state` | `open` while the answer is being written; `aborted` when the call was stopped or failed. |
| `source` | Who is writing, in the shape of an item's `source`. |
| `blocks` | The text written since the previous frame, one entry for each block of the answer. |

Each entry of `blocks` holds:

| Field | Meaning |
| :- | :- |
| `index` | The block's position in the final message. |
| `type` | `text` or `reasoning`. |
| `delta` | The new text of that block. A reader appends it to the block at `index`. |

Deltas are coalesced: a frame is sent at most every 250 milliseconds, about four a second. A successful answer sends no
closing frame, because the stored item or object event replaces the partial message at once. A reader that wants the
complete text reads the stored item.

A partial message is sent only when the answer is written to a place a session follows: a session
[thread](https://docs.blobhub.io/blob-types/workflow/workflows/component-data-thread.md) or a session object. An answer written to an
execution-persisted output streams nothing, because nobody can follow it. A partial message never fails the call: a
connection that cannot be reached is skipped.

## What is not streamed

Tool calls and images arrive with the final message. A partial message carries only `text` and `reasoning` blocks.

## Stop

A streamed call checks for a stop every few seconds. When the execution is being stopped, the call is abandoned: it
writes nothing, its partial message ends with a frame whose `state` is `aborted`, and the component ends on its
`failure` route after posting this warning:

`The execution is stopping: the answer was discarded and nothing was written.`

A call that fails for any other reason after it sent a partial message also ends it with `aborted`.

## Following partial messages

A connection [listener](https://docs.blobhub.io/web-socket/server/listener.md#partial-messages) without `batch` receives the partial messages its
[filter](https://docs.blobhub.io/blob-types/workflow/workflows/event-filter.md) matches: one without a `types` clause receives them too, and
`"partial"` in a `types` list selects them. The `aliases` and `executions` filters select them as they select events.
A listener added with `batch` receives none.

```json theme={null}
{
  "jsonrpc": "2.0",
  "id": 2,
  "method": "listener/add",
  "params": {
    "revision_id": "0A06AB3A-DD72-4D42-939A-61DC4EF69418",
    "session": "28E70055-DBB4-4CA8-88BC-133D6CEA68E6",
    "filter": {"types": ["partial", "thread.item_posted"], "aliases": ["conversation"]}
  }
}
```

A partial message arrives as the `event` of a `listener/event` frame, as described on
[Listener](https://docs.blobhub.io/web-socket/server/listener.md#partial-messages). It has no event `id`, so it never moves a follower's stream
cursor, and no REST route returns one.

* A follower that joins while an answer is being written sees the rest of it.
* A reader that arrives afterwards sees only what was stored.
* A follower that drew a partial message replaces it when the item with its `item_id` arrives, and drops it on
  `aborted`.

The playground follows partial messages this way: its listener's filter holds `partial`, its conversation widget draws
the partial message at the thread's tail and replaces it with the stored item, and a message widget bound to the
output's alias shows it while it is open. Ordinary reads, REST and the event stream's listing, never return a partial
message.


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.