Back to Blog
Tutorial

Lisa Chen7 min
Ctrl+R

You trust your agent to automate repetitive tasks, but sometimes it hits a gate where human judgment matters. Maybe the agent needs approval to install software, or a task requires a manual credential entry. Instead of failing or looping forever, the runs API lets you pause the agent, notify a human, and resume exactly where it left off. This is human in the loop automation with awaiting_human and resume.

How awaiting_human works in runs

When you start a task run, you set on_awaiting_human to pause. The agent continues executing steps until it reaches a point where it must wait. The run transitions to the awaiting_human state and stops. You can then poll GET /v1/runs/{id} to confirm the state, optionally send a webhook notification, and let a human approve or deny. Once the human approves, call POST /v1/runs/{id}/resume to continue execution. The agent resumes from the last successful step, using the same max_steps, deadline_seconds, and other parameters you set in the original run.

python
import os
import requests
from urllib.parse import urljoin

BASE_URL = "https://coasty.ai/v1"
API_KEY = os.getenv("COASTY_API_KEY")
HEADERS = {
    "Authorization": f"Bearer {API_KEY}",
    "Content-Type": "application/json",
}

def start_run():
    url = urljoin(BASE_URL, "/runs")
    payload = {
        "machine_id": "my-macbook-pro",
        "task": "Install the latest Firefox and open https://coasty.ai/docs",
        "cua_version": "v4",
        "on_awaiting_human": "pause",
        "max_steps": 200,
        "deadline_seconds": 3600,
        "webhook_url": "https://example.com/webhooks/coasty-run",
    }
    resp = requests.post(url, json=payload, headers=HEADERS)
    resp.raise_for_status()
    return resp.json()

def get_run(run_id):
    url = urljoin(BASE_URL, f"/runs/{run_id}")
    resp = requests.get(url, headers=HEADERS)
    resp.raise_for_status()
    return resp.json()

def resume_run(run_id):
    url = urljoin(BASE_URL, f"/runs/{run_id}/resume")
    resp = requests.post(url, headers=HEADERS)
    resp.raise_for_status()
    return resp.json()

if __name__ == "__main__":
    run = start_run()
    run_id = run["id"]
    print(f"Started run {run_id}, state: {run['state']}")

    # Human approves and signals resume
    print("Waiting for human approval...")
    # In production, check webhook or poll here
    # ...

    resumed = resume_run(run_id)
    print(f"Resumed run {run_id}, state: {resumed['state']}")

Run lifecycle and states

  • queued: the run is queued for execution.
  • running: the agent is actively working on the task.
  • awaiting_human: the run paused and is waiting for approval via resume.
  • succeeded: the agent completed all steps without errors.
  • failed: the agent encountered an unrecoverable error.
  • cancelled: the run was canceled via POST /v1/runs/{id}/cancel,
  • timed_out: the run exceeded deadline_seconds.

Set on_awaiting_human to pause, poll for the awaiting_human state, then resume with POST /v1/runs/{id}/resume to continue execution.

Where awaiting_human beats brittle automation

Traditional automation often relies on brittle selectors or API endpoints that change without notice. If an element moves or an API deprecates a field, your script fails. A computer use agent driven by the runs API sees the screen and mimics human actions, so it adapts to layout changes, UI updates, and dynamic content. Pausing for human approval adds a safety net for critical decisions, credential prompts, or policy checks. This combination lets you build automation that is both flexible and trustworthy.

Use awaiting_human and resume to orchestrate safe, human-in-the-loop automation. Build workflows that pause, let you verify or intervene, and then continue. Get your API key and start building at https://coasty.ai/developers.

© 2026 Coasty

Backed byYCombinator