Expand description
Streamed-turn assembly for AgentRun.
A streamed model turn arrives as incremental StreamedAssistantContent
items. StreamedTurnAssembler is the sans-IO accumulator that turns that
item stream into the same canonical complete turn the non-streaming path
feeds the machine — while telling the driver what to forward to its
consumer and surfacing invalid tool calls the moment they appear, so a
driver can stop paying for a doomed provider stream early.
The protocol, paired with the streamed entry points on
AgentRun:
- On
AgentRunStep::CallModel, open a provider stream and create one assembler per turn with the tool names advertised for that turn. - Feed every stream item to
StreamedTurnAssembler::ingestand act on the returnedStreamedTurnEvents: forward items to the consumer, and onStreamedTurnEvent::InvalidToolCallconsultAgentRun::resolve_streamed_invalid_tool_call—StreamedResolution::Repairedcontinues the same stream viaStreamedTurnAssembler::resolve_pending_invalid;StreamedResolution::TurnAbandonedmeans drain the provider stream for usage and re-enterAgentRun::next_step. - When the provider stream ends, call
StreamedTurnAssembler::finishand feed the result toAgentRun::streamed_turn; the run then proceeds exactly like a non-streamed one (CallTools/Done).
crate::streaming::StreamingPrompt::stream_prompt drives this protocol
internally; hand-driven runs can use it to stream any
AgentRun.
Structs§
- Partial
Streamed Turn - Snapshot of a streamed turn at the moment an invalid tool call appeared. Used by the machine to build diagnostics and rollback messages from exactly what the model has produced so far.
- Streamed
Invalid Tool Call - One invalid tool call surfaced mid-stream, awaiting a resolution from
AgentRun::resolve_streamed_invalid_tool_call. - Streamed
Turn - The assembled streamed turn, fed to
AgentRun::streamed_turn. - Streamed
Turn Assembler - Sans-IO accumulator that assembles one streamed model turn. See the module docs for the driving protocol.
Enums§
- Streamed
Resolution - What the machine decided about a mid-stream invalid tool call.
- Streamed
Turn Event - What a driver must do with one ingested stream item.