Fully autonomous agents fail when they hit ambiguous UI, missing data, or policy gates. Instead of hard-coding fallbacks for every edge case, you can let a computer use agent drive the session and pause when it needs human input. The awaiting_human state tells you exactly when to step in, and the POST /v1/runs/{id}/resume endpoint lets you continue execution with a corrected instruction.
How awaiting_human and resume work
When you start a task run with POST /v1/runs, the server launches a computer use agent on a cloud VM. The agent captures the screen, predicts actions, and executes them. If the agent encounters a situation it cannot resolve, it emits status="awaiting_human" in the event stream. At that point, the server does not proceed to the next agent step. To resume, you send a POST request to /v1/runs/{id}/resume with a new instruction field that describes what the human wants. The agent receives the updated instruction and continues from where it left off, still billed $0.05 per step. The runs API does not require you to re-provision a machine or reset the session.
import os
import requests
import json
import time
COASTY_API_KEY = os.getenv("COASTY_API_KEY")
BASE_URL = "https://coasty.ai/v1"
def start_run():
url = f"{BASE_URL}/runs"
headers = {
"X-API-Key": COASTY_API_KEY,
"Content-Type": "application/json",
}
payload = {
"machine_id": "<your-provisioned-machine-id>",
"task": "Open Chrome and navigate to https://example.com",
"cua_version": "v3",
"max_steps": 30,
"deadline_seconds": 600,
"on_awaiting_human": "pause",
}
resp = requests.post(url, headers=headers, json=payload)
resp.raise_for_status()
return resp.json()
def stream_events(run_id):
url = f"{BASE_URL}/runs/{run_id}/events"
headers = {
"X-API-Key": COASTY_API_KEY,
"Accept": "text/event-stream",
}
resp = requests.get(url, headers=headers, stream=True)
for line in resp.iter_lines():
if line:
line = line.decode("utf-8")
if line.startswith("data:"):
data = json.loads(line[5:])
print(data)
yield data
def resume_run(run_id, instruction):
url = f"{BASE_URL}/runs/{run_id}/resume"
headers = {
"X-API-Key": COASTY_API_KEY,
"Content-Type": "application/json",
}
payload = {"instruction": instruction}
resp = requests.post(url, headers=headers, json=payload)
resp.raise_for_status()
return resp.json()
if __name__ == "__main__":
run = start_run()
run_id = run["run_id"]
print(f"Started run {run_id}")
for event in stream_events(run_id):
status = event.get("status")
if status == "awaiting_human":
print("Agent paused. Send your instruction to resume.")
break
resume = resume_run(run_id, "Click the Accept button on the consent page.")
print("Resumed run", resume["run_id"])
for event in stream_events(run_id):
if event.get("status") in ["succeeded", "failed"]:
print("Run finished", event)
breakKey fields and billing
- POST /v1/runs requires machine_id, task, and optional cua_version (default v3).
- on_awaiting_human can be "pause" (default), "fail", or "cancel" to control agent behavior.
- max_steps sets the maximum number of agent steps (billed $0.05 each).
- deadline_seconds caps total runtime before a timeout.
- If status is "awaiting_human", the run stays in that state until you resume it.
- Billed $0.05 per agent step regardless of whether a human intervenes.
When the event stream returns status: awaiting_human, POST /v1/runs/{id}/resume with an updated instruction to let the agent proceed.
Where this beats brittle automation
Selector-based frameworks break when UI changes, dynamic IDs appear, or labels shift. A computer use agent reads the actual screen, understands context, and asks a human for clarification. You stay in control of the process flow, but offload the execution to the runs API. You can chain multiple runs, enforce budgets, and enforce deadlines via the DSL or API without writing custom parsers for every application.
Build workflows that handle unknown UI by pausing when the agent hits a decision point. Use awaiting_human and resume to keep sessions alive, correct course, and keep costs predictable. Get a key and start building at https://coasty.ai/developers.
Want to see this in action?
View Case Studies