The Workflow DSL Explained: task, assert, if, loop, parallel
Writing a single-step task is easy. But real workflows need branching, retries, assertions, and parallel execution. Coasty provides a versioned JSON DSL so you can describe a whole pipeline in one request. POST /v1/workflows lets you define tasks, asserts, conditionals, loops, and parallel branches, then spin up runs that execute the DSL against a provisioned machine_id.
Core DSL step types
- ●task: Executes a computer use agent step. Billed $0.05 per step. Requires a task string and optional instructions.
- ●assert: Evaluates a condition, fails the workflow if false. Useful for verifying UI state or data before proceeding.
- ●if: Conditionally runs a branch of steps. The condition is a structured object with fields like equals, contains, exists, etc.
- ●loop: Repeats a block of steps for a fixed number of iterations or until a condition becomes true.
- ●parallel: Executes multiple branches concurrently. Each branch is a full workflow DSL. Useful for side-effect tasks or parallel data fetching.
- ●human_approval, retry, succeed, fail: Control flow helpers for pausing for human input, retrying on error, and finalizing the workflow.
curl -X POST https://coasty.ai/v1/workflows \ -H "Content-Type: application/json" \ -H "X-API-Key: $COASTY_API_KEY" \ -d '{
"version": "1.0",
"name": "example-workflow",
"steps": [
{
"id": "start",
"type": "task",
"task": "Open Chrome and navigate to https://example.com",
"instructions": ""
},
{
"id": "assert_title",
"type": "assert",
"condition": {
"type": "equals",
"field": "page_title",
"value": "Example Domain"
}
},
{
"id": "if_loaded",
"type": "if",
"condition": {
"type": "exists",
"field": "h1"
},
"then": [
{
"id": "capture",
"type": "task",
"task": "Take a screenshot of the page"
}
],
"else": [
{
"id": "retry_load",
"type": "retry",
"max_attempts": 3,
"backoff_seconds": 2,
"step": {
"id": "reload",
"type": "task",
"task": "Reload the page"
}
}
]
},
{
"id": "parallel_fetch",
"type": "parallel",
"branches": [
{
"id": "branch_a",
"steps": [
{
"id": "task_a",
"type": "task",
"task": "Open a new tab and visit https://api.github.com"
}
]
},
{
"id": "branch_b",
"steps": [
{
"id": "task_b",
"type": "task",
"task": "Open a new tab and visit https://example.org"
}
]
}
]
},
{
"id": "finalize",
"type": "succeed"
}
],
"budget_cents": 1000,
"max_iterations": 100,
"deadline_seconds": 600
}'Running a workflow
- ●POST /v1/workflows creates a workflow and returns an id.
- ●POST /v1/workflows/{id}/runs starts a run, passing a machine_id and any double-brace variables like {{input.url}}.
- ●Each task step is billed $0.05. Parallel branches increase total cost linearly.
- ●Use GET /v1/workflows/{id}/runs to list runs and GET /v1/runs/{id} to inspect individual run state: queued, running, awaiting_human, succeeded, failed, cancelled, timed_out.
- ●Webhook_url lets you receive events via Server-Sent Events (GET /v1/runs/{id}/events) and reconnect with Last-Event-ID.
POST /v1/workflows defines your pipeline once; runs execute it against any provisioned machine_id.
Where this beats brittle automation
Traditional automation relies on fragile selectors or scraping APIs that change without notice. With Coasty, the workflow DSL drives a real desktop via the computer use agent. You assert on visible elements and page content, branch on those conditions, loop until a state is stable, and parallelize independent tasks. This lets you build robust agents that adapt to UI changes and require fewer manual scripts.
Start building multi-step computer use agents with the Coasty Workflow DSL. Create your workflow, pick a machine_id, and launch runs. Get your API key at https://coasty.ai/developers and try your first workflow today.