When running browser agent tasks through the Index API, you can receive real-time updates as the agent executes rather than waiting for the entire task to complete. This is particularly useful for:

  • Providing immediate feedback to users
  • Showing progress indicators for long-running tasks
  • Enabling early termination if needed
  • Debugging agent behavior in real-time

Streaming Mode

To receive real-time updates as the browser agent executes:

import { LaminarClient } from '@lmnr-ai/lmnr';

const client = new LaminarClient({
  projectApiKey: "YOUR_PROJECT_API_KEY",
});

async function runStreamingBrowserAgent() {
  const response = await client.agent.run({
    prompt: "Lookup the current weather for New York, London, and Tokyo and compare them.",
  });
  
  for await (const chunk of response) {
    if (chunk.chunkType === 'step') {
      // Print step-by-step actions as they happen
      console.log(`Step: ${chunk.summary}`);
    } else if (chunk.chunkType === 'finalOutput') {
      // Print the final result
      console.log(`Final output: ${chunk.content.result.content}`);
    }
  }
}

runStreamingBrowserAgent();

Chunk Types

When streaming browser agent output, you’ll receive different types of chunks that represent various aspects of the agent’s execution:

Chunk TypeDescription
stepA step taken by the agent during execution (e.g., navigating to a page, clicking a button)
finalOutputThe final result of the agent’s execution