Human in the Loop: Awaiting Human and Resume in the Runs API
Bots crash on CAPTCHAs, confirmations, or anything that looks like a human decision. The Coasty Runs API gives you a human-in-the-loop mode so agents can pause and wait for approval before continuing. This guide shows how to set on_awaiting_human, handle the paused state, and resume your runs with a single API call.
How it works
When you create a task run with on_awaiting_human set to pause, the agent executes until it encounters a step that needs human input. The run moves to the awaiting_human state instead of failing. You then poll GET /v1/runs or stream events until you see that state. Once you approve the action, you call POST /v1/runs/{id}/resume to let the agent continue. The server bills $0.05 per agent step regardless of the paused state.
curl -X POST https://coasty.ai/v1/runs \
-H "X-API-Key: $COASTY_API_KEY" \
-H "Content-Type: application/json" \
-d '{
"machine_id": "m-123",
"task": "Open Chrome and navigate to https://example.com",
"cua_version": "v4",
"on_awaiting_human": "pause",
"max_steps": 50,
"deadline_seconds": 900
}'
Handling the paused run
- ●Poll GET /v1/runs to see the status field change to awaiting_human
- ●Stream events with GET /v1/runs/{id}/events to receive status updates in real time
- ●Wait for the human approval step (the server includes the human instruction in the event details)
- ●Do not cancel or retry the run; use resume instead to continue from the paused state
import os
import requests
import json
def create_run():
url = "https://coasty.ai/v1/runs"
headers = {
"X-API-Key": os.getenv("COASTY_API_KEY"),
"Content-Type": "application/json"
}
payload = {
"machine_id": "m-123",
"task": "Open Chrome and navigate to https://example.com",
"cua_version": "v4",
"on_awaiting_human": "pause",
"max_steps": 50,
"deadline_seconds": 900
}
r = requests.post(url, headers=headers, json=payload)
r.raise_for_status()
return r.json()
def get_run(run_id):
url = f"https://coasty.ai/v1/runs/{run_id}"
headers = {"X-API-Key": os.getenv("COASTY_API_KEY")}
r = requests.get(url, headers=headers)
r.raise_for_status()
return r.json()
if __name__ == "__main__":
run = create_run()
run_id = run["id"]
print("Created run", run_id)
# Poll or stream events until status is awaiting_human
# Once the human approves, call resume_run(run_id)
Set on_awaiting_human to pause when you want the agent to stop and wait for human approval instead of failing.
Where this beats brittle automation
Traditional tools rely on brittle selectors, fixed URLs, or API-only integrations that break when a page changes. The Coasty computer use agent sees the screen like a human, navigates with clicks and typing, and handles CAPTCHAs, confirmations, and dynamic UIs. With on_awaiting_human you keep the bot running while you review and approve critical steps, so it does not crash and you do not need to rewrite selectors for every change.
Add human oversight to your computer use agent. Create a run with on_awaiting_human set to pause, wait for the awaiting_human state, and resume with POST /v1/runs/{id}/resume. Get your API key at https://coasty.ai/developers and start building resilient automation workflows.