Tutorial

Stream Live Agent Progress with SSE and Last-Event-ID

David Park||7 min
Ctrl+Z

You just spun up a task run with POST /v1/runs, and you want to know the state and see the events as they happen. Webhooks are great for notifications, but they cannot show you the full history or let you reconnect after a network hiccup. Use Server-Sent Events (SSE) and Last-Event-ID to stream all events from /v1/runs/{id}/events. This gives you a live, ordered feed of every step your computer use agent takes.

How it works

Start a task run with POST /v1/runs specifying a machine_id, task, and cua_version. The server responds with an ID. Open an SSE connection to GET /v1/runs/{id}/events. The server streams Server-Sent Events with fields like id, event, and data. Reconnect with Last-Event-ID to resume from the last event, ensuring you never miss a step.

bash
curl -N -H "X-API-Key: $COASTY_API_KEY" https://coasty.ai/v1/runs/abc123/events

Request and response details

  • POST /v1/runs requires machine_id, task, and cua_version (default v3).
  • On success, the server returns a JSON object with an id field.
  • GET /v1/runs/{id}/events streams SSE events with fields id, event, data.
  • Reconnect with Last-Event-ID header set to the last event id you received.
  • Event types include queued, running, awaiting_human, succeeded, failed, cancelled, timed_out.
  • Each event contains a JSON payload with details like step, reason, and timestamp.

Use Last-Event-ID to reconnect and resume the SSE stream exactly where it left off.

Where this beats brittle automation

Computer use agents see the screen and act like a human, so they can adapt to UI changes that break CSS selectors. Streaming events lets you observe each click, keystroke, and parse result in real time. You can build dashboards that show the agent's progress, log every action, and react instantly when it hits an error or awaits human approval. You do not need brittle XPath or CSS selectors. You just watch the stream and trust the agent's actions.

You now know how to stream live agent progress with SSE and Last-Event-ID. Build a live dashboard, log all events, and handle reconnections cleanly. Get your API key at https://coasty.ai/developers and start streaming your computer use agent today.

Want to see this in action?

View Case Studies
Try Coasty Free