Tutorial

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

Emily Watson||8 min
Ctrl+Z

Automated desktop agents often hit a wall when they need approval, credentials, or confirmation. Without a pause, the agent either fails or worse, makes an irreversible change. The Runs API solves this with on_awaiting_human and a dedicated resume endpoint. You can pause a run, request human input, and then continue exactly where it left off. This feature is core to building safe, verifiable computer use automation.

How it works

When you create a run, you can set on_awaiting_human to 'pause', 'fail', or 'cancel'. With 'pause', the server transitions the run state to 'awaiting_human' and emits an event. You inspect the run status and events, collect the human decision, and then call POST /v1/runs/{id}/resume with the necessary context. The agent continues from the last step, preserving the full trajectory. The billing model remains consistent at $0.05 per agent step regardless of pauses.

bash
Create a paused run with on_awaiting_human=pause and resume it later.

1. Start the run:

export COASTY_API_KEY

curl -X POST https://coasty.ai/v1/runs \ 
  -H "Authorization: Bearer $COASTY_API_KEY" \ 
  -H "Content-Type: application/json" \ 
  -d '{
    "machine_id": "m-12345",
    "task": "Install the latest version of curl and verify it",
    "cua_version": "v4",
    "on_awaiting_human": "pause",
    "max_steps": 20,
    "deadline_seconds": 600
  }'

2. Poll for status until you see "awaiting_human" in the events stream:

export RUN_ID="<returned id>"

curl -s https://coasty.ai/v1/runs/$RUN_ID \ 
  -H "Authorization: Bearer $COASTY_API_KEY"

3. Once you have human input, resume the run:

curl -X POST https://coasty.ai/v1/runs/$RUN_ID/resume \ 
  -H "Authorization: Bearer $COASTY_API_KEY" \ 
  -H "Content-Type: application/json" \ 
  -d '{
    "human_context": "User approved the installation"
  }'

4. Optionally cancel if you decide not to proceed:

curl -X POST https://coasty.ai/v1/runs/$RUN_ID/cancel \ 
  -H "Authorization: Bearer $COASTY_API_KEY"

Field reference

  • machine_id: required, the cloud VM identifier.
  • task: required, the high-level goal for the agent.
  • cua_version: default 'v3', 'v4' enables autonomous pass/fail verification.
  • on_awaiting_human: one of 'pause', 'fail', 'cancel'. 'pause' is the default behavior for human-in-the-loop workflows.
  • max_steps: optional, upper bound on agent steps.
  • deadline_seconds: optional, seconds before timeout.
  • webhook_url: optional, for async completion notifications.
  • Resume request body: human_context is optional, any string you want to pass to the agent for the next round.

Set on_awaiting_human="pause" when you need human input, then resume with POST /v1/runs/{id}/resume.

Where this beats brittle automation

Traditional automation relies on CSS selectors, XPath, or brittle APIs that break when UI changes. The Coasty computer use agent sees the screen, understands context, and can wait for human approval. You do not need to hardcode selectors for buttons, input boxes, or confirmation dialogs. The agent works with the actual UI, so it adapts to layout shifts, new icons, or renamed fields. Pausing and resuming adds a safety layer without sacrificing adaptability.

Use on_awaiting_human to pause for approvals, credentials, or verification, and resume exactly where you left off. This makes computer use automation reliable and safe. Build workflows that handle real-world edge cases instead of brittle selectors. Get your API key at https://coasty.ai/developers and start building human-in-the-loop automation.

Want to see this in action?

View Case Studies
Try Coasty Free