Skip to main content

Module stream

Module stream 

Source
Expand description

Agent streaming state machine.

This module is responsible only for scheduling and polling — it does not contain any business logic. All “do actual work” functions live in executor:

AgentStream::poll_next
  │
  ├─ Idle              → spawn run_summarize future
  ├─ Summarizing       → poll future → ConnectingStream | FetchingResponse
  ├─ FetchingResponse  → poll future → YieldingToolCalls | Done  (yield Token)
  ├─ ConnectingStream  → poll future → StreamingChunks
  ├─ StreamingChunks   → poll inner stream → yield Token | YieldingToolCalls | Done
  ├─ YieldingToolCalls → drain queue → ExecutingTools  (yield ToolCall per item)
  ├─ ExecutingTools    → poll future → YieldingToolResults
  ├─ YieldingToolResults → drain queue → Idle  (yield ToolResult per item)
  └─ Done              → Poll::Ready(None)

Structs§

AgentStream
Drives an agent through one or more API turns, tool-execution rounds, and summarization passes, emitting AgentEvents as a Stream.