Stream Live Agent Progress with SSE and Last-Event-ID
You spin up a computer use agent with POST /v1/runs. It runs a task on a cloud VM and you want to show each step to your users. Polling GET /v1/runs/{id} is slow and noisy. SSE streams events in real time and Last‑Event‑ID lets you reconnect safely after a disconnect.
How it works
Create a run with POST /v1/runs. Include machine_id, task, and cua_version. The server returns a run_id. Open a GET /v1/runs/{id}/events stream. The server pushes Server‑Sent Events (SSE) with fields like event, state, message, and result. If the connection drops, send the Last‑Event‑ID header in the next request to resume from that event.
#!/bin/bash
# Stream a live task run with SSE and Last-Event-ID
COASTY_API_KEY="${COASTY_API_KEY}"
RUN_ID="your-run-id-here"
# First request, no Last-Event-ID
curl -N -s "https://coasty.ai/v1/runs/${RUN_ID}/events" \
-H "X-API-Key: ${COASTY_API_KEY}" \
-H "Accept: text/event-stream"
# If you reconnect, send the Last-Event-ID header
# curl -N -s "https://coasty.ai/v1/runs/${RUN_ID}/events" \
# -H "X-API-Key: ${COASTY_API_KEY}" \
# -H "Accept: text/event-stream" \
# -H "Last-Event-ID: <value-from-previous-response>"Run flow and states
- ●queued: The request is accepted.
- ●running: The agent is executing steps (billed $0.05 per step).
- ●awaiting_human: The agent paused for human input.
- ●succeeded, failed, cancelled, timed_out: Final states.
GET /v1/runs/{id}/events streams events. Use Last-Event-ID to reconnect safely.
Where this beats brittle automation
Selectors break when layouts change. API-only tools require stable endpoints. Computer use agents see the screen and act like a human. You can stream their full progress, pauses, and failures directly to your UI. This keeps your app responsive and shows real work, not just polling status.
Wire SSE + Last-Event-ID into your UI to show live agent progress. Build dashboards for task runs, human approval flows, and debugging. Get an API key at https://coasty.ai/developers.