Skip to main content
Learn how to stream agent responses in real-time, providing immediate feedback and better user experience for long-running tasks.

Overview

Streaming enables:
  • Real-time output as the agent thinks
  • Better user experience with immediate feedback
  • Progress monitoring for long tasks
  • Integration with dashboards and UIs
  • Token-by-token response visualization

Basic Streaming

Enable streaming with a simple flag:

Streaming with Callback

Use callbacks to process streaming tokens in real-time:

Advanced Streaming Modes

1. Detailed Streaming (stream=True)

Get detailed token information with metadata:
With stream=True the callback receives one token_info dict per token. The text is under "token"; the dict also carries token_index, model, id, created, finish_reason, usage, logprobs, and timestamp. Detailed mode also prints each token_info and a final chunk summary to stdout.
A streaming_callback only fires when the agent is streaming, so set streaming_on=True (string tokens) or stream=True (token_info dicts). Without either, the callback is ignored and the agent makes a normal, non-streaming call.

2. Silent Streaming

Collect chunks without printing:

3. Custom Streaming Panel

Create custom visual displays:

Streaming in Multi-Agent Workflows

Concurrent Workflow with Streaming

Sequential Workflow with Streaming

Streaming Configuration

Agent-Level Configuration

Runtime Configuration

Real-World Examples

1. WebSocket Integration

2. Progress Bar Integration

3. File Logging

Best Practices

1. Buffer Management

2. Error Handling

3. Rate Limiting

Output Examples

Basic Streaming Output

Concurrent Workflow Dashboard

Troubleshooting

Streaming Not Working

Tokens Not Appearing

Next Steps

Learn More