Engineering

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

David Park||5 min
Ctrl+C

You spin up a cloud VM, submit a task, and want to show users the status in real-time. The /v1/runs/{id}/events endpoint streams Server-Sent Events (SSE) with state changes. If the connection drops, Last-Event-ID lets you resume from the last received event. This avoids polling and keeps your dashboard in sync with the agent.

How it works

Submit a task with POST /v1/runs. Store the ID returned. Open a GET /v1/runs/{id}/events connection. The server streams events with a Last-Event-ID header if you reconnect. States include queued, running, awaiting_human, succeeded, failed, cancelled, timed_out. Each event contains run_id, state, and optional data. Reconnecting with Last-Event-ID ensures you do not miss state updates.

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

Reconnecting with Last-Event-ID

  • GET /v1/runs/{id}/events streams events. Each event includes a Last-Event-ID header.
  • On reconnect, set the Last-Event-ID header to the value from the last received event.
  • The server resumes streaming from that point and continues to send new states.
  • This pattern works across network flakiness, browser refreshes, or backend restarts.

Use Last-Event-ID when reconnecting to /v1/runs/{id}/events to resume streaming from the last received event.

Where this beats brittle automation

Computer use agents see the screen and act like a human. They handle dynamic UI, unexpected errors, and missing selectors. The /v1/runs API gives you full visibility into what the agent does. Combining this with SSE and Last-Event-ID lets you build dashboards that show exactly where the agent is and what it is doing, without brittle XPath or CSS selectors.

Start building real-time dashboards for your computer use agents. Use Last-Event-ID to reconnect safely. Get your API key at https://coasty.ai/developers.

Want to see this in action?

View Case Studies
Try Coasty Free