> ## Documentation Index
> Fetch the complete documentation index at: https://browseruse-0aece648-magnus-concurrency-docs.mintlify.site/llms.txt
> Use this file to discover all available pages before exploring further.

# Live messages

> Stream the agent's messages in real time to build custom UIs or monitor progress.

<Note>
  Want a ready-made UI? See the [Chat UI tutorial](/cloud/tutorials/chat-ui).
</Note>

Stream messages as the agent works — reasoning, tool calls, browser actions, and results. Each message has `role`, `type`, `summary`, `data`, and `screenshot_url`. See [List session messages](/cloud/api-v3/sessions/list-session-messages) for all fields.

<CodeGroup>
  ```python Python theme={null}
  from browser_use_sdk.v3 import AsyncBrowserUse

  client = AsyncBrowserUse()

  run = client.run("Find the top story on Hacker News")
  async for msg in run:
      print(f"[{msg.role}] {msg.summary}")

  print(run.result.output)
  ```

  ```typescript TypeScript theme={null}
  import { BrowserUse } from "browser-use-sdk/v3";

  const client = new BrowserUse();

  const run = client.run("Find the top story on Hacker News");
  for await (const msg of run) {
    console.log(`[${msg.role}] ${msg.summary}`);
  }

  console.log(run.result.output);
  ```
</CodeGroup>

```
[user] Find the top story on Hacker News
[assistant] Navigating to https://news.ycombinator.com/
[tool] Browser Navigate: Navigated
[assistant] Analyzing browser state
[tool] Browser Analyze State: The top story is "Coding Agents Could Make Free Software Matter Again"
[tool] Done Autonomous: The top story on Hacker News is "Coding Agents Could Make Free Software Matter Again"
```

## Manual polling

If you need full control over the polling loop (e.g. custom interval, filtering):

<CodeGroup>
  ```python Python theme={null}
  import asyncio
  from browser_use_sdk.v3 import AsyncBrowserUse

  client = AsyncBrowserUse()
  session = await client.sessions.create(task="Find the top story on Hacker News")

  cursor = None
  while True:
      msgs = await client.sessions.messages(session.id, after=cursor, limit=100)
      for m in msgs.messages:
          print(f"[{m.role}] {m.summary}")
          cursor = m.id

      s = await client.sessions.get(session.id)
      if s.status.value in ("idle", "stopped", "error", "timed_out"):
          break
      await asyncio.sleep(2)

  print(s.output)
  ```

  ```typescript TypeScript theme={null}
  import { BrowserUse } from "browser-use-sdk/v3";

  const client = new BrowserUse();
  const session = await client.sessions.create({
    task: "Find the top story on Hacker News",
  });

  let cursor: string | undefined;
  while (true) {
    const msgs = await client.sessions.messages(session.id, { after: cursor, limit: 100 });
    for (const m of msgs.messages) {
      console.log(`[${m.role}] ${m.summary}`);
      cursor = m.id;
    }

    const s = await client.sessions.get(session.id);
    if (["idle", "stopped", "error", "timed_out"].includes(s.status)) {
      console.log(s.output);
      break;
    }
    await new Promise((r) => setTimeout(r, 2000));
  }
  ```
</CodeGroup>

## Related

* [Live preview & recording](/cloud/browser/live-preview) — embed the browser alongside your message stream
* [Follow-up tasks](/cloud/agent/follow-up-tasks) — chain multiple tasks in one session while streaming each
