The Workflow DSL Explained: Task, Assert, If, Loop, Parallel
Building automation that persists across sessions or needs to react to dynamic UIs is hard with brittle selectors. The Coasty Workflow DSL solves this by giving you a versioned JSON DSL to orchestrate task runs. You define steps such as task, assert, if, loop, parallel, and more, and the server drives agents to completion, handling retries, waiting, and human approval along the way. Each task step costs $0.05 per agent step, billed against your prepaid USD wallet.
Workflow DSL Overview
- ●You POST a Workflow JSON to /v1/workflows. This creates a versioned definition that other calls can reference.
- ●You start a workflow run with POST /v1/workflows/{id}/runs, or ad-hoc inline with POST /v1/workflows/runs.
- ●The workflow is a JSON object with a top-level type 'workflow', a version, and a list of steps.
- ●Supported step types include task, assert, if, loop, parallel, human_approval, retry, succeed, fail.
- ●Conditions are structured objects that can reference variables like {{inputs.x}} or stepId.field.
- ●Guards such as budget_cents, max_iterations, and deadline_seconds enforce hard limits.
- ●Each task step triggers a $0.05 per agent step charge when the server executes it.
Step Types in Detail
- ●task: Runs the task prompt. The server executes a computer use agent until the task is done or fails.
- ●assert: Validates that a condition holds. It can reference captured fields from previous steps or inputs.
- ●if: Branches execution based on a condition. If true, it runs a list of steps; otherwise, it runs an else list.
- ●loop: Iterates over an array. Each iteration can assign values to variables and run task or assert steps.
- ●parallel: Runs a list of steps concurrently. Useful for touching multiple UI elements or endpoints at once.
- ●human_approval: Pauses the workflow and waits for manual approval before proceeding.
- ●retry: Retries a task or block on failure, configurable with delay and max attempts.
- ●succeed: Marks the workflow run as succeeded and stops execution.
- ●fail: Marks the workflow run as failed and stops execution.
Request and Response
When you create a workflow, you POST an object to /v1/workflows. The response includes an id and version. Later, you start a run with /v1/workflows/{id}/runs, passing a machine_id and a task. The run object returns its id and an initial state. You can stream events from /v1/runs/{id}/events to see progress. The run state can be queued, running, awaiting_human, succeeded, failed, cancelled, or timed_out. Each task step inside the workflow costs $0.05 per agent step and is deducted from your prepaid USD wallet.
curl -X POST https://coasty.ai/v1/workflows \
-H "X-API-Key: $COASTY_API_KEY" \
-H "Content-Type: application/json" \
-d '{
"type": "workflow",
"version": 1,
"steps": [
{
"type": "task",
"description": "Open browser to https://example.com and take a screenshot.",
"id": "open_home"
},
{
"type": "assert",
"condition": "{{open_home.screenshot}} contains 'Example Domain'",
"message": "Expected title not found."
},
{
"type": "if",
"condition": "{{inputs.retry_on_fail}}",
"then": [
{
"type": "retry",
"step_id": "open_home",
"max_attempts": 3,
"delay_seconds": 2
}
],
"else": [
{
"type": "succeed",
"message": "Workflow completed."
}
]
}
],
"guards": {
"budget_cents": 1000,
"max_iterations": 10,
"deadline_seconds": 300
}
}'Running a Workflow
Once you have a workflow id, you start a run by POSTing to /v1/workflows/{id}/runs. You must provide a machine_id and a task. The run object returns its id and the initial state. You can GET /v1/runs/{id} to poll the final state, or stream events with GET /v1/runs/{id}/events. If the workflow requires human approval, the state becomes awaiting_human. You can cancel with POST /v1/runs/{id}/cancel or resume with POST /v1/runs/{id}/resume. Each task step inside the workflow is billed $0.05 per agent step.
curl -X POST https://coasty.ai/v1/workflows/abc123/runs \
-H "X-API-Key: $COASTY_API_KEY" \
-H "Content-Type: application/json" \
-d '{
"machine_id": "vm-001",
"task": "Navigate to https://example.com and confirm the title contains Example Domain.",
"instructions": "Use the browser and take screenshots to verify the title.",
"cua_version": "v4"
}'curl -X GET https://coasty.ai/v1/runs/run-xyz \
-H "X-API-Key: $COASTY_API_KEY"curl -X GET https://coasty.ai/v1/runs/run-xyz/events \
-H "X-API-Key: $COASTY_API_KEY" \
-H "Accept: text/event-stream"Where This Beats Brittle Automation
Selector-based automation breaks when UI changes or elements are dynamically generated. The Coasty Workflow DSL lets you describe intent rather than fragile selectors. A workflow can assert on what it sees, branch based on conditions, loop over arrays, and run multiple tasks in parallel. The server executes the workflow on a real machine, using computer use to navigate, click, type, and capture screenshots. Each task step is billed $0.05 per agent step, but you get reliable, stateful automation that adapts to the UI as it appears.
Define intent with task, assert, if, loop, and parallel steps, and let the server drive the agent to completion.
Start building stateful computer use agents with the Coasty Workflow DSL. Create workflows with task, assert, if, loop, parallel, and other steps, then start runs on real machines. Each task step costs $0.05 per agent step and is billed against your prepaid USD wallet. Get a key at https://coasty.ai/developers and try it out today.