Streaming Live Agent Progress with SSE and Last-Event-ID
Most computer use APIs only give you a final job status. You fire a task, wait, then get 'succeeded' or 'failed'. Coasty gives you a stream of events for each task run, so you can show live progress on a dashboard, retry failed steps, or pause when the agent asks for human approval. Use GET /v1/runs/{id}/events to receive Server-Sent Events, and reconnect with Last-Event-ID to resume reading from where you left off.
How it works
When you start a task run with POST /v1/runs, the server returns an ID. To see live progress, call GET /v1/runs/{id}/events. This endpoint emits Server-Sent Events, one per state change. Typical event types include queued, running, awaiting_human, succeeded, failed, cancelled, and timed_out. Each event contains a timestamp and the current state. To reconnect after a network hiccup, include the Last-Event-ID header with the ID of the last event you received. The server resumes streaming from the next event after that ID.
#!/bin/bash
# Stream live events for a task run
COASTY_API_KEY="${COASTY_API_KEY}"
RUN_ID="your-task-run-id-here"
# Use curl with --no-buffer to avoid buffering SSE
curl -sS --no-buffer \
-H "X-API-Key: $COASTY_API_KEY" \
-H "Accept: text/event-stream" \
"https://coasty.ai/v1/runs/${RUN_ID}/events" \
| while IFS= read -r line; do
echo "$line"
# Extract the event ID if present (SSE format: id: <id>)
if [[ $line =~ ^id: ([^ ]+) ]]; then
LAST_EVENT_ID="${BASH_REMATCH[1]}"
fi
done
# To reconnect after interruption, pass the last event ID:
# curl -sS --no-buffer \
# -H "X-API-Key: $COASTY_API_KEY" \
# -H "Accept: text/event-stream" \
# -H "Last-Event-ID: $LAST_EVENT_ID" \
# "https://coasty.ai/v1/runs/${RUN_ID}/events"Event types you will see
- ●queued: the job entered the processing queue
- ●running: the agent has started processing the task
- ●awaiting_human: the agent paused and is waiting for human input or approval
- ●succeeded: the task completed successfully
- ●failed: the task completed with an error
- ●cancelled: the run was canceled by the client
- ●timed_out: the deadline_seconds limit was reached
Always include Last-Event-ID on reconnects to resume streaming from the next event.
Where this beats brittle automation
Traditional automation relies on brittle selectors, XPath, or specific DOM attributes that break when UI changes. Coasty's computer use agent sees the screen and acts like a human, so you do not need to maintain fragile selectors. By streaming events, you can react to real-time states such as awaiting_human and pause or retry specific steps. This makes your automation resilient to UI updates and lets you show live progress in your own dashboards.
Start streaming live agent progress with SSE and Last-Event-ID on /v1/runs/{id}/events. Build dashboards that show queue times, active steps, and human approval requests. Get your API key at https://coasty.ai/developers and start building resilient computer use agents.