Overview
Thestream() method streams a conversation turn, yielding events incrementally. Each call sends one user message and yields events until the agent finishes its turn.
Method Signature
Parameters
str
required
User message text to send to the agent.
str | None
default:"None"
Thread ID for conversation context. Auto-generated if None.
str
default:"client default"
Override the model for this specific call.
bool
default:"client default"
Override thinking mode for this call.
bool
default:"client default"
Override plan mode for this call.
bool
default:"client default"
Override subagent delegation for this call.
int
default:"100"
Maximum number of agent steps per turn.
Return Value
YieldsStreamEvent objects with the following structure:
object
A single event from the streaming agent response.
Event Types
Event types align with the LangGraph SSE protocol:messages-tuple Events
Per-message updates emitted as the agent processes:
AI Text Message
AI Tool Call
Tool Result
values Events
Full state snapshot after each agent step:
end Event
Signals stream completion:
Examples
Basic Streaming
Tool Call Detection
State Snapshots
Multi-Tool Chain
StreamEvent Class
TheStreamEvent dataclass is defined as:
LangGraph SSE Protocol Alignment
Event types and data structures match the LangGraph SSE protocol so consumers can switch between HTTP streaming and embedded mode without changing their event-handling logic.
Protocol Mapping
Migration Example
HTTP Gateway client:Testing
From the live test suite:See Also
- Chat - For simple request/response
- Configuration - For file operations and model selection
- Overview - For initialization options