When running complex browser automation tasks, you may want to see the agent’s output in real-time rather than waiting for the entire task to complete. Index provides streaming capabilities that allow you to see the agent’s actions and thought process as they happen.

Basic Streaming Example

Here’s how to stream the agent’s output:

async for chunk in agent.run_stream(
    prompt="Go to news.ycombinator.com, find a post about AI, and summarize it"
):
    if chunk.type == "step":
        print(chunk.content)
    elif chunk.type == "final_output":
        print(chunk.content)