Tutorial

Human in the Loop Automation: awaiting_human and resume in the runs API

Sarah Chen||8 min
Ctrl+F

Most web automation breaks when sites change a class name or move a button. You need a method that can see the screen and decide what to do next. The Coasty runs API gives you that ability. You start an agent, let it run autonomously, and switch into human-in-the loop mode when the agent hits a situation it cannot resolve on its own. It waits in the awaiting_human state. You provide approval, and the API resumes the run with full memory of the previous steps. This approach is safer than brittle selectors and works with any desktop app, browser, or terminal.

How it works

To enable human-in-the loop automation, create a run with the on_awaiting_human parameter set to "pause". The agent runs with the cua_version you choose, usually "v3" or the autonomous "v4". When the agent reaches a decision point that requires human input, the run transitions to the awaiting_human state instead of continuing or failing. You check the run status with GET /v1/runs/{id}. When the status is awaiting_human, you pause execution. After you provide the human decision, call POST /v1/runs/{id}/resume with the approved action. The server resumes the agent from the last known state, preserving all trajectory memory from predictive calls. The on_awaiting_human option can also be "fail" or "cancel" if you want the run to end automatically instead of waiting.

bash
curl https://coasty.ai/v1/runs \ 
  -H "X-API-Key: $COASTY_API_KEY" \ 
  -H "Content-Type: application/json" \ 
  -d '{ 
    "machine_id": "m-12345", 
    "task": "Navigate to https://example.com, find the login button, and click it", 
    "cua_version": "v3", 
    "on_awaiting_human": "pause" 
  }'

Key parameters and pricing

  • on_awaiting_human: "pause" makes the run wait for a resume call ("fail" or "cancel" also available).
  • cua_version: "v3" is the default, "v4" is autonomous with a pass/fail verifier.
  • GET /v1/runs/{id} returns status, steps, and events to detect awaiting_human.
  • POST /v1/runs/{id}/resume accepts the human-approved action and continues execution.
  • Task steps are billed at $0.05 per agent step when using the runs API.

Set on_awaiting_human to "pause" to enter human-in-the-loop mode, then call POST /v1/runs/{id}/resume with the approved action to continue.

Where this beats brittle automation

Traditional automation relies on CSS selectors, XPath, or element IDs. When a site updates its markup, these selectors break and the entire workflow fails. Coasty computer use agents see the screen just like a human. They can open pages, inspect buttons, read text, and decide what to do next based on visual context. The runs API remembers the trajectory, so when you resume, the agent continues from the correct point with full memory. This combination makes your automation resilient to UI changes and capable of handling complex workflows that cannot be expressed with simple selectors. You get the reliability of scripted tools with the flexibility of human-like behavior.

Now you can build automation that pauses for approval, resumes safely, and handles any UI. Try it with your own workflow and get an API key from https://coasty.ai/developers. The runs API is your bridge between autonomous agents and human judgment.

Want to see this in action?

View Case Studies
Try Coasty Free