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

# Live messages

> Poll the agent's message history 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>

Poll `sessions.messages()` while a task runs to get the agent's reasoning, tool calls, and results.

<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")
  session_id = str(session.id)

  seen = set()
  while True:
      msgs = await client.sessions.messages(session_id, limit=100)
      for m in msgs.messages:
          if str(m.id) not in seen:
              seen.add(str(m.id))
              print(f"[{m.role}] {m.data[:200]}")

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

  ```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",
  });

  const seen = new Set<string>();
  while (true) {
    const msgs = await client.sessions.messages(session.id, { limit: 100 });
    for (const m of msgs.messages) {
      if (!seen.has(m.id)) {
        seen.add(m.id);
        console.log(`[${m.role}] ${m.data.slice(0, 200)}`);
      }
    }

    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>

Each message has a `role` (`user`, `assistant`, `tool`), a `summary` for display, and a `type` (e.g. `browser_action`, `browser_action_result`). Browser action results include a `screenshot_url`. See [List session messages](/cloud/api-v3/sessions/list-session-messages) for all fields.
