Skip to main content

Module stream

Module stream 

Source
Expand description

Line buffering for streaming text.

Structured protocols (ACP, Claude stream-json, Codex app-server) emit text in small chunks. Treating every chunk as a separate output would turn transcripts into one character per line. StreamBuf reassembles chunks into complete lines and flushes on kind switches or turn end.

Structsยง

Chunk
Text ready to emit. When append is true, the first segment of text continues the previously emitted line that had no trailing newline (see StreamBuf::idle_flush_chunk).
StreamBuf
Buffer that coalesces token-level chunks into complete lines.