Event Stream
@llm_chat calls return an AsyncGenerator[ReactOutput, None]; @llm_function exposes the same event stream through fn.stream(...). Each yielded item is either a response (final output) or an event (lifecycle signal).
ReactOutput
ResponseYield
Contains the final agent output:EventYield
Contains a lifecycle event:The 14 Event Types
Loop Lifecycle
| Event | When | Key Fields |
|---|---|---|
ReactStartEvent | ReAct loop begins | — |
ReactIterationStartEvent | New iteration starts | iteration |
ReactIterationEndEvent | Iteration completes | iteration |
ReactEndEvent | Loop terminates | final_messages, response |
LLM Call
| Event | When | Key Fields |
|---|---|---|
LLMCallStartEvent | Before calling the provider | messages (what the LLM sees) |
LLMChunkArriveEvent | Each streaming chunk | chunk (text delta) |
LLMCallEndEvent | LLM response complete | usage, content, response, messages |
LLMCallErrorEvent | LLM call failed | error |
Tool Execution
| Event | When | Key Fields |
|---|---|---|
ToolCallsBatchStartEvent | Tool batch begins | tool_calls |
ToolCallStartEvent | Single tool starts | tool_name, tool_call_id, arguments |
ToolCallArgumentsDeltaEvent | Streaming tool args | delta |
ToolCallEndEvent | Tool completes | tool_name, result, execution_time, success |
ToolCallErrorEvent | Tool failed | tool_name, error |
ToolCallsBatchEndEvent | All tools in batch done | — |
Custom Events
| Event | When | Key Fields |
|---|---|---|
CustomEvent | Tool emits custom data | event_name, data, tool_call_id |
ToolEventEmitter — used for streaming tool output (e.g., PyRepl stdout, shell output).
Convenience Filters
EventOrigin (Fork Routing)
When using SelfRef forks, events come from multiple agents.EventOrigin identifies the source: