Coasty Workflow DSL Explained: Task, Assert, If, Loop, Parallel
Most agent APIs want you to write a single step and call predict repeatedly. Coasty lets you define a complete, versioned workflow as a JSON DSL and POST it to /v1/workflows. You can chain tasks, assert states, branch on results, loop over retries, or run parallel subtasks. The server then provisions real machines, runs the workflow, and streams events back to you. This post walks through each step type, shows a real JSON payload, and explains the $0.05 per agent step billing.
Workflow DSL overview
- ●Workflows are versioned JSON DSLs uploaded to POST /v1/workflows.
- ●The root object is a list of steps (task, assert, if, loop, parallel, human_approval, retry, succeed, fail).
- ●Each step has an id, type, and any type-specific fields like input, instructions, or conditions.
- ●Variables are referenced with the double-brace syntax {{inputs.x}} or stepId.field.
- ●Hard guards include budget_cents, max_iterations, and deadline_seconds at each step or globally.
- ●Task steps are billed $0.05 each, the same as a single agent step on a machine.
Step types in detail
- ●task: runs a full agent step on a real desktop or browser. You can append instructions to the base prompt.
- ●assert: checks a condition on the current state (e.g., element visible, text match) and fails the workflow if false.
- ●if: branches execution based on a condition object. The true branch and false branch are lists of steps.
- ●loop: repeats a block of steps while a condition holds or up to max_iterations.
- ●parallel: runs multiple substeps concurrently and waits for all to finish before continuing.
- ●human_approval: pauses the workflow until you approve. Options are pause, fail, or cancel on_awaiting_human.
- ●retry: retries a task with exponential backoff if it fails, using a max_attempts and delay_ms.
- ●succeed: ends the workflow with success. Marks the run as succeeded.
- ●fail: ends the workflow with failure. Marks the run as failed.
#!/bin/bash
# POST a workflow to Coasty using curl.
# Reads COASTY_API_KEY from the environment.
export COASTY_API_KEY
# Replace with your own workflow JSON
WORKFLOW='{
"id": "example-workflow",
"version": "1.0",
"steps": [
{
"id": "login_task",
"type": "task",
"instructions": "Navigate to https://example.com/login, enter email, enter password, click submit."
},
{
"id": "check_logged_in",
"type": "assert",
"condition": {
"type": "visible",
"selector": "text=Welcome",
"timeout_ms": 5000
}
},
{
"id": "if_logged_in",
"type": "if",
"condition": {
"type": "not",
"value": {
"type": "visible",
"selector": "text=Welcome"
}
},
"true": [
{
"id": "fail_no_login",
"type": "fail",
"message": "Login did not succeed."
}
],
"false": [
{
"id": "continue",
"type": "succeed"
}
]
}
],
"max_iterations": 5,
"deadline_seconds": 300
}'
# POST the workflow
RESPONSE=$(curl -s -X POST https://coasty.ai/v1/workflows \
-H "Authorization: Bearer $COASTY_API_KEY" \
-H "Content-Type: application/json" \
-d "$WORKFLOW")
# Show the response
echo "Response: $RESPONSE"
Running a workflow
- ●After creating a workflow, POST to /v1/workflows/{id}/runs to start it.
- ●Each run gets a run id. GET /v1/runs/{id} gives the status and summary.
- ●Use GET /v1/runs/{id}/events to stream Server-Sent Events for progress, errors, and final state.
- ●The server reuses a machine from provisioned machines and drives the agent on a real desktop.
- ●If a run times out or exceeds budget_cents, the step fails and the workflow can continue or stop depending on on_awaiting_human.
- ●Cancel a running workflow with POST /v1/runs/{id}/cancel.
- ●Resume a paused workflow with POST /v1/runs/{id}/resume.
Every task step is billed $0.05 per agent step on a machine.
Where this beats brittle automation
Traditional automation relies on brittle selectors, XPath, or APIs that may change without notice. The Coasty workflow DSL drives agents on real desktops and browsers using computer use, meaning the agent sees the screen, reads text, and clicks elements like a human. You can assert that a UI element is visible before proceeding, branch based on dynamic states, loop over retries, or run parallel tasks like file uploads, cleanup, and validation. The DSL is versioned, so you can ship workflows as code and roll back safely. This gives you robust, maintainable, and scalable automation without hand-tuned selectors.
Start building your own versioned workflows with task, assert, if, loop, and parallel steps. The Coasty computer use API handles machine provisioning, event streaming, and billing. Get a key and start experimenting at https://coasty.ai/developers.