Skip to main content

Module streaming_assertions

Module streaming_assertions 

Source
Expand description

Shared streaming-virtual-fields module for e2e test codegen.

Chat-stream fixtures assert on “virtual” fields that don’t exist on the stream result type itself — chunks, chunks.length, stream_content, stream_complete, no_chunks_after_done, tool_calls, finish_reason. These fields resolve against the collected list of chunks produced by draining the stream.

StreamingFieldResolver provides two entry points:

§Convention

The chunks_var parameter is the local variable name that holds the collected list (default: "chunks"). The stream_var parameter is the result variable produced by the stream call (default: "result").

The set of streaming-virtual field names handled by this module:

  • chunks → the collected list itself
  • chunks.length → length/count of the collected list
  • stream_content → concatenation of all delta content strings
  • stream_complete → boolean — last chunk has a non-null finish_reason
  • no_chunks_after_done → structural invariant (true by construction for channel/iterator-based APIs once the channel is closed; emitted as assert!(true) / assertTrue for languages without post-DONE chunk plumbing)
  • tool_calls → flat list of tool_calls from all chunk deltas
  • finish_reason → finish_reason string from the last chunk

Structs§

StreamingFieldResolver
Shared streaming-virtual-fields resolver for e2e test codegen.

Constants§

STREAMING_VIRTUAL_FIELDS
The set of field names treated as streaming-virtual fields.

Functions§

is_streaming_virtual_field
Returns true when field is a streaming-virtual field name.