Back to Blog
Engineering

Sophia Martinez8 min
⌘+T

You spin up a computer use agent, wait for it to finish, and only then see the final result. That works for demos but breaks in production. You need live visibility into what your agent is doing right now, and you need to survive temporary network blips. The Coasty computer use API provides streaming progress via Server-Sent Events and Last-Event-ID, so your dashboard always reflects the current state of any task run.

How it works

Create a task run with POST /v1/runs. Set a webhook_url if you want push notifications, but you can also poll with GET /v1/runs or GET /v1/runs/{id}. For streaming, open GET /v1/runs/{id}/events as a Server-Sent Events stream. Each event carries a state field that matches the documented states: queued, running, awaiting_human, succeeded, failed, cancelled, timed_out. The stream stays open until the run finishes. If the connection drops, send Last-Event-ID in a subsequent request header to resume from the last known event. This gives you reliable, real-time progress without polling.

bash
Create a task run, then stream its events. Replace YOUR_API_KEY and YOUR_MACHINE_ID with real values from https://coasty.ai/developers/keys.

# Step 1: Start the run
RUN_ID=$(curl -s -X POST https://coasty.ai/v1/runs \
  -H "X-API-Key: $COASTY_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "machine_id": "YOUR_MACHINE_ID",
    "task": "Install Python 3.12 and create a virtual environment",
    "cua_version": "v4",
    "max_steps": 200,
    "deadline_seconds": 600
  }' | jq -r '.id')

# Step 2: Stream events (retry with Last-Event-ID on disconnect)
while true; do
  curl -N \
    -H "X-API-Key: $COASTY_API_KEY" \
    -H "Last-Event-ID: $LAST_ID" \
    https://coasty.ai/v1/runs/$RUN_ID/events
  LAST_ID=$(curl -s -N -D - -H "X-API-Key: $COASTY_API_KEY" -H "Last-Event-ID: $LAST_ID" https://coasty.ai/v1/runs/$RUN_ID/events | grep -i '^Last-Event-ID:' | cut -d' ' -f2)
  sleep 1
done

Understanding the stream

  • Events are Server-Sent Events (SSE) over plain HTTP.
  • Each event has a state field: queued, running, awaiting_human, succeeded, failed, cancelled, timed_out.
  • The stream closes when the run reaches a terminal state.
  • Header Last-Event-ID lets you resume after a disconnect.
  • You can also poll GET /v1/runs/{id} or GET /v1/runs for the same state.

Always send Last-Event-ID on reconnect to avoid missing queued or running events.

Where this beats brittle automation

Traditional automation relies on brittle selectors and fixed API endpoints. If a UI changes, your script breaks. A computer use agent perceives the screen, understands instructions, and adapts to changes. When you stream live states, you see not just final success or failure, but also when the agent encounters something it cannot resolve (awaiting_human) or times out. This visibility lets you intervene, adjust prompts, or fallback to alternative workflows. You stop guessing and start acting based on real-time telemetry.

Build dashboards that show exactly what your computer use agent is doing right now, handle network interruptions with Last-Event-ID, and react to states like awaiting_human without waiting for the final result. Get a key at https://coasty.ai/developers and start streaming your agent progress.

© 2026 Coasty

Backed byYCombinator