pub struct ChunkNormalizer { /* private fields */ }Expand description
Expands chunk events into the explicit events the rest of the protocol is written in.
Feed every event of a run through it, in order, and apply what comes out. Events that are not chunks pass through untouched, after the end of whatever chunk stream they close.
Implementations§
Source§impl ChunkNormalizer
impl ChunkNormalizer
Sourcepub fn is_open(&self) -> bool
pub fn is_open(&self) -> bool
Whether a chunk stream is currently open: one a chunk opened and nothing has ended yet.
Sourcepub fn normalize(&mut self, event: Event, out: &mut Vec<Event>) -> Result<()>
pub fn normalize(&mut self, event: Event, out: &mut Vec<Event>) -> Result<()>
Expands one event, appending the result to out.
Appends the synthesized end of each stream the event closes, then for a chunk the synthesized start of the stream it opens and its content, and for any other event the event itself.
§Errors
A chunk that names no stream and has none to continue — none open, or several subagents’ open and no attribution to pick one — or a tool call chunk that opens a call without naming the tool, is a protocol violation: there is no id to attach the payload to, and guessing one would put text in the wrong message. So is a continuation chunk that contradicts what its stream was opened with. Nothing is appended and nothing changes when a chunk is rejected.