Human in the Loop Automation: Awaiting_Human and Resume with the Runs API
Automated agents often encounter things they cannot resolve, such as multi-factor authentication prompts, secret approvals, or UI elements that change. Blocking your pipeline on these events can stall entire workflows. The runs API lets you pause a computer use agent at a specific point and wait for human input. Once you approve the action, you can resume the run so the agent continues executing without a full restart. This pattern keeps your automation resilient and predictable.
How it works
When a run enters the awaiting_human state, the agent stops and waits. You can inspect the current step, the screenshot, and any metadata attached to that step. To resume, you send a POST request to /v1/runs/{id}/resume. The request body includes any data you want to pass to the agent, such as a user approval token, a secret value, or a note. After the resume, the agent continues from where it paused. The billing continues at $0.05 per agent step as long as the run is in the running state.
import os
import requests
from typing import Optional
COASTY_API_KEY = os.getenv("COASTY_API_KEY")
BASE_URL = "https://coasty.ai/v1"
def resume_run(run_id: str, approval_token: Optional[str] = None) -> dict:
"""Resume a paused run with optional approval token."""
url = f"{BASE_URL}/runs/{run_id}/resume"
headers = {
"Authorization": f"Bearer {COASTY_API_KEY}",
"Content-Type": "application/json"
}
body = {}
if approval_token:
body["approval_token"] = approval_token
response = requests.post(url, headers=headers, json=body)
response.raise_for_status()
return response.json()
# Example usage
if __name__ == "__main__":
run_id = "your-run-id-from-get-runs-or-events"
print(resume_run(run_id, approval_token="user-approved-123"))Key parameters and behaviors
- ●Run ID is the identifier returned by GET /v1/runs or from a Server-Sent Events stream.
- ●The resume endpoint accepts optional fields like approval_token that the agent can use to proceed.
- ●The run returns to the running state and continues executing steps until it reaches succeeded, failed, cancelled, or timed_out.
- ●Billing is $0.05 per agent step as long as the run is in the running state.
- ●You can cancel a run at any time using POST /v1/runs/{id}/cancel if you decide to abort.
Resume a run with POST /v1/runs/{id}/resume to let the computer use agent continue after human approval.
Where this beats brittle automation
Traditional automation relies on fixed selectors and API endpoints that change when a website updates or when a new security step appears. Computer use agents that see the screen can detect new UI elements and ask for human guidance instead of failing. The await_human state gives you a stable pause point that is not tied to specific DOM structures or element IDs. Combine this with the runs API, and you can build adaptive workflows that handle approvals, secrets, and edge cases without rewriting your automation for every change.
Add resilient automation pipelines that pause for human input and continue seamlessly. Use the await_human state and resume endpoint in your computer use agent workflows. Get a key and start building at https://coasty.ai/developers.