Engineering

Human in the Loop Automation: Awaiting Human and Resume in the Runs API

Alex Thompson||5 min
Tab

Most automation fails on edge cases where a human decision is needed. Instead of hard‑coding every guardrail, you can let the agent pause automatically and wait for approval. The Runs API supports this via the awaiting_human state and the resume endpoint. The agent keeps its trajectory in memory, so when you resume, it picks up exactly where it left off.

How it works

Submit a task run with on_awaiting_human set to pause. The server processes the initial steps, bills $0.05 per agent step, and eventually emits an awaiting_human event via Server‑Sent Events. At that point the run stays in memory and you call POST /v1/runs/{id}/resume with the human approval. The API then continues from the last successful step, billing another $0.05 per step until completion. States include queued, running, awaiting_human, succeeded, failed, cancelled, and timed_out.

bash
curl -X POST https://coasty.ai/v1/runs \
  -H "X-API-Key: $COASTY_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "machine_id": "m-12345",
    "task": "Install the latest Python driver and run a smoke test",
    "cua_version": "v4",
    "on_awaiting_human": "pause",
    "max_steps": 200,
    "deadline_seconds": 600
  }'

Resume a paused run

  • Use the run ID returned by the initial POST /v1/runs call.
  • POST /v1/runs/{id}/resume accepts no body.
  • Billing continues at $0.05 per agent step after resumption.
  • The agent preserves the trajectory from the last successful step.
python
import os
import requests

API_KEY = os.getenv("COASTY_API_KEY")
BASE_URL = "https://coasty.ai/v1"
RUN_ID = "r-abcde"

resp = requests.post(f"{BASE_URL}/runs/{RUN_ID}/resume",
                     headers={"X-API-Key": API_KEY})
resp.raise_for_status()
print("Run resumed, status:", resp.json()["status"])

on_awaiting_human: pause lets the Runs API emit awaiting_human events, then resume picks up exactly where it left off.

Where this beats brittle automation

Automation based on brittle selectors or hard‑coded waits breaks when UI changes or when you hit an unknown approval screen. With the computer use API, the agent sees the screen, understands that it needs human approval, and enters the awaiting_human state. You can decide how to handle that state, pause for a UI approval step, cancel, or fail the run. When you resume, the agent continues with the full trajectory, not a subset of actions.

Add checkpoints to your workflows by leveraging awaiting_human and the resume endpoint. This lets your computer use agent handle approvals, data entry, and edge cases without brittle selectors. Get your API key at https://coasty.ai/developers and start building resilient, human‑in‑the‑loop automation.

Want to see this in action?

View Case Studies
Try Coasty Free