agentix.streaming¶
streaming ¶
Streaming types.
Two layers of events:
- Model stream — what a streaming model yields: zero or more
:class:
TextDeltachunks, then exactly one :class:ResponseCompletecarrying the full :class:ModelResponse(text + tool calls + tokens). - Agent stream — what :meth:
Agent.streamyields to you: :class:AnswerDelta(incremental answer text), :class:ToolStarted/ :class:ToolFinishedaround each tool call, and a terminal :class:Donecarrying the full :class:AgentOutcome.
A model that supports streaming implements :class:StreamingModelFn (an async
stream method). The loop falls back to non-streaming if it doesn't.
StreamingModelFn ¶
Bases: Protocol
A model that can stream. stream yields TextDelta chunks then one
ResponseComplete with the assembled response.
AnswerDelta
dataclass
¶
Incremental text of the model's response for the current turn.
chunk_text ¶
Split text into word-ish chunks for a realistic fake stream.