Tutorial

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

David Park||5 min
Ctrl+F

Automated agents can only go so far without context. When a task needs approval, a security check, or a manual override, the agent should pause rather than fail. The Coasty Runs API supports this with the awaiting_human state and a resume endpoint. You get streaming events, clear status values, and predictable billing. In this guide you will see exactly how to pause for human input and continue later.

How awaiting_human works

  • POST /v1/runs creates a task run with optional on_awaiting_human, a webhook URL, max_steps and deadline_seconds.
  • When the agent reaches a decision point it transitions to awaiting_human instead of failing.
  • The run stays in memory until you call POST /v1/runs/{id}/resume or POST /v1/runs/{id}/cancel.
  • GET /v1/runs/{id}/events streams Server-Sent Events with type and payload including status and any user-provided data.
  • Status values include queued, running, awaiting_human, succeeded, failed, cancelled, timed_out.
  • Billed $0.05 per agent step regardless of state.
  • The on_awaiting_human field can be pause, fail, or cancel to define the default when no human acts.
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 a 7-day trial of an app and start it",
    "cua_version": "v4",
    "on_awaiting_human": "pause",
    "webhook_url": "https://your-domain.com/hooks/coasty",
    "max_steps": 50,
    "deadline_seconds": 600
  }'

Resuming a paused run

  • Call POST /v1/runs/{id}/resume with any optional data to pass back to the agent.
  • The agent continues from the last state and uses the new data to proceed.
  • The endpoint does not incur extra billing beyond the remaining steps.
  • You can also cancel the run with POST /v1/runs/{id}/cancel or POST /v1/runs/{id}/resume with failure data.
bash
curl -X POST https://coasty.ai/v1/runs/{run_id}/resume \
  -H 'X-API-Key: $COASTY_API_KEY' \
  -H 'Content-Type: application/json' \
  -d '{
    "data": {
      "human_approval": true,
      "reason": "License key accepted"
    }
  }'

Use awaiting_human to pause for decisions and POST /v1/runs/{id}/resume to continue with user-provided data.

Where this beats brittle automation

Traditional automation relies on brittle selectors, hardcoded IDs and fragile API wrappers. If a UI changes the selector breaks and the pipeline fails. The Coasty computer use agent sees the screen, follows natural language instructions, and can wait for approval. With awaiting_human you can design workflows that stop at checkpoints, collect human input, and resume with confidence. This approach remains robust across version changes and reduces false positives without complex selector maintenance.

Human-in-the-loop automation becomes practical when you can pause, resume, and stream events cleanly. Build approval gates, security checks, or fallback paths in your pipelines using the awaiting_human state and resume endpoint. Get a key at https://coasty.ai/developers and start building resilient agents today.

Want to see this in action?

View Case Studies
Try Coasty Free