| title | Live messages |
|---|---|
| description | Poll the agent's message history in real time to build custom UIs or monitor progress. |
| icon | message-lines |
Poll sessions.messages() while a task runs to get the agent's reasoning, tool calls, and results.
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
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));
}
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 for all fields.