Introduction
CrewAI Flows support streaming output, allowing you to receive real-time updates as your flow executes. This feature enables you to build responsive applications that display results incrementally, provide live progress updates, and create better user experiences for long-running workflows.How Flow Streaming Works
When streaming is enabled on a Flow, CrewAI captures and streams output from any crews, LLM calls, tools, and lifecycle events within the flow. The stream delivers orderedStreamFrame items with printable content plus structured event data as execution progresses.
Enabling Streaming
To enable streaming, set thestream attribute to True on your Flow class:
Code
Synchronous Streaming
When you callkickoff() on a flow with streaming enabled, it returns a stream session that yields ordered StreamFrame items:
Code
Stream Item Information
Each item provides both printable content and structured event data:Code
Accessing Streaming Properties
The stream session provides useful properties and methods:Code
Asynchronous Streaming
For async applications, usekickoff_async() with async iteration:
Code
Streaming with Multi-Step Flows
Streaming works seamlessly across multiple flow steps, including flows that execute multiple crews:Code
Practical Example: Progress Dashboard
Here’s a complete example showing how to build a progress dashboard with streaming:Code
Streaming with State Management
Streaming works naturally with Flow state management:Code
Use Cases
Flow streaming is particularly valuable for:- Multi-Stage Workflows: Show progress across research, analysis, and synthesis phases
- Complex Pipelines: Provide visibility into long-running data processing flows
- Interactive Applications: Build responsive UIs that display intermediate results
- Monitoring and Debugging: Observe flow execution and crew interactions in real-time
- Progress Tracking: Show users which stage of the workflow is currently executing
- Live Dashboards: Create monitoring interfaces for production flows
Stream Frame Channels
Flow streaming yieldsStreamFrame items across several channels:
LLM Frames
Standard text content from LLM responses:Code
Tool Frames
Information about tool calls within the flow:Code
Error Handling
Handle errors gracefully during streaming:Code
Cancellation and Resource Cleanup
The stream session supports graceful cancellation so that in-flight work stops promptly when the consumer disconnects.Async Context Manager
Code
Explicit Cancellation
Code
streaming.is_cancelled and streaming.is_completed are both True. Both aclose() and close() are idempotent.
Important Notes
- Streaming automatically enables LLM streaming for any crews used within the flow
- You must iterate through all stream items before accessing the
.resultproperty - Streaming works with both structured and unstructured flow state
- Flow streaming captures output from all crews and LLM calls in the flow
- Each frame includes structured event context such as channel, type, namespace, and payload
- Streaming adds minimal overhead to flow execution
Combining with Flow Visualization
You can combine streaming with flow visualization to provide a complete picture:Code
