Tutorial

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

James Liu||5 min
Del

Most automation breaks when a UI changes or a step needs clarification. Instead of retrying with brittle selectors, let the computer use agent pause and ask for approval, then resume automatically once you respond. The runs API handles the state, the server tracks progress, and you only intervene when really needed.

How awaiting_human works in the runs API

When you create a run, you can tell the agent what to do when it gets stuck waiting for human input. Use the on_awaiting_human parameter to control behavior. Valid values are pause, fail, or cancel. A value of pause lets the agent stop and wait. The run state becomes awaiting_human. You then call resume to continue. The agent proceeds from the last known screen and actions, using its trajectory memory from the session.

bash
curl https://coasty.ai/v1/runs \
  -H "X-API-Key: $COASTY_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "machine_id": "machine-123",
    "task": "Open the project dashboard in Chrome and take a screenshot",
    "cua_version": "v4",
    "on_awaiting_human": "pause",
    "max_steps": 50,
    "deadline_seconds": 300
  }'

When the run enters awaiting_human

  • The run state is awaiting_human after the agent hits a step that needs clarification or approval.
  • You can check the status with GET /v1/runs/{id}. The response includes current state and a short message.
  • The agent keeps its trajectory via sessions, so it continues from where it left off when you resume.
  • Resuming sends the last known screen and actions back to the agent, letting it proceed without missing context.

Set on_awaiting_human: "pause" then call POST /v1/runs/{id}/resume to continue after approval.

Resume a paused run

Once you have approved or clarified the step, send a resume request. The agent takes over again and keeps going until the task succeeds, fails, or hits a time or step limit. This pattern is ideal for tasks that sometimes need a human decision. The agent never has to re-explain itself because it remembers everything.

bash
curl https://coasty.ai/v1/runs/{run_id}/resume \
  -H "X-API-Key: $COASTY_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "message": "User approved the step, continue with the dashboard task"
  }'

Where this beats brittle automation

Traditional automation relies on fixed selectors, IDs, or API endpoints that can break when a UI updates. A computer use agent sees the screen like a human, can handle dynamic text, and can pause for approval. It reasons through the interface step by step, so you do not need brittle XPath or CSS selectors. The runs API manages state, so you can pause and resume without complex logic in your own code.

Use awaiting_human and resume in the runs API to build automation that stops when it needs help, then continues automatically. This pattern lets you handle edge cases and human decisions without brittle selectors. Get your API key and start building at https://coasty.ai/developers.

Want to see this in action?

View Case Studies
Try Coasty Free