Skip to main content
Use agent.stream(...) when users or operators should see progress during a browser-agent run.
const stream = agent.stream({
  startUrl: "https://www.sec.gov/edgar/search/",
  goal: "Find Apple's latest 10-Q filings and return filing metadata.",
});

for await (const event of stream) {
  if (event.type === "browser.created") {
    console.log("Browser", event.browserId);
  }

  if (event.type === "tool.completed") {
    console.log("Step", event.step, event.page?.title ?? event.page?.url);
  }

  if (event.type === "confirmation.requested") {
    console.log("Needs confirmation", event.request.message);
  }

  if (event.type === "run.completed") {
    console.log(event.result.status);
    console.log(event.result.text);
  }
}

Events to handle

EventUse it for
run.startedCreate a job record or progress row.
browser.createdStore the browser ID and optional debug capability.
tool.completedShow the latest browser step, page title, or URL.
observationTrack how much page evidence the agent saw.
artifactStore files, downloads, or generated evidence.
confirmation.requestedAsk a human or policy service for a decision.
run.completedPersist the final result and route by event.result.status.

Logging rules

  • Do not log raw secrets.
  • Do not log signed Debug UI or CDP URLs unless your log store is trusted for bearer capabilities.
  • Store source URLs and status so operators can review the run later.
  • Keep user-facing progress short; put verbose diagnostics behind an operator view.