The Workflow DSL Explained: Task, Assert, If, Loop, Parallel
Most computer use agents run a single task and stop. You need to chain steps, retry on failure, branch logic, and run checks in parallel. The Coasty Workflow DSL gives you a versioned JSON DSL for task, assert, if, loop, and parallel steps. You POST the DSL to POST /v1/workflows, then POST /v1/workflows/{id}/runs, and the server drives the agent to completion. Each task step is billed $0.05 per agent step.
How the Workflow DSL works
A Workflow is a versioned JSON object. POST /v1/workflows creates it. The DSL supports step types: task, assert, if, loop, parallel, human_approval, retry, succeed, fail. Task steps call the agent to execute instructions on a machine. Assert steps verify a state and fail the workflow if the condition is false. If steps branch based on conditions. Loop steps repeat a sub-workflow. Parallel steps run multiple workflows concurrently. Variables follow the double-brace syntax {{inputs.x}} or stepId.field. Hard guards include budget_cents, max_iterations, deadline_seconds.
import os
import requests
import json
BASE_URL = "https://coasty.ai/v1"
API_KEY = os.getenv("COASTY_API_KEY")
HEADERS = {
"Authorization": f"Bearer {API_KEY}",
"Content-Type": "application/json",
}
def create_workflow():
payload = {
"version": "1.0",
"steps": [
{
"type": "task",
"name": "open_browser",
"task": "Open Chrome, navigate to https://coasty.ai/docs",
"cua_version": "v3"
},
{
"type": "assert",
"name": "page_loaded",
"condition": "title contains 'Coasty'",
"timeout_seconds": 30
},
{
"type": "if",
"name": "show_welcome",
"condition": "{{inputs.welcome}} == true",
"steps": [
{
"type": "task",
"name": "print_welcome",
"task": "Print 'Welcome to Coasty' to the terminal",
"cua_version": "v3"
}
]
},
{
"type": "loop",
"name": "process_items",
"max_iterations": 5,
"iterations": "{{process_items.iteration}}",
"steps": [
{
"type": "task",
"name": "click_item",
"task": "Click the first item in the list",
"cua_version": "v3"
},
{
"type": "assert",
"name": "item_selected",
"condition": "selected_item == true",
"timeout_seconds": 15
}
]
},
{
"type": "parallel",
"name": "run_checks",
"steps": [
{
"type": "task",
"name": "check_network",
"task": "Ping www.google.com",
"cua_version": "v3"
},
{
"type": "task",
"name": "check_disk",
"task": "Run 'df -h' and capture output",
"cua_version": "v3"
}
]
},
{
"type": "succeed"
}
]
}
resp = requests.post(f"{BASE_URL}/workflows", headers=HEADERS, json=payload)
resp.raise_for_status()
return resp.json()
if __name__ == "__main__":
workflow = create_workflow()
print("Workflow created:", workflow)
Run a workflow
- ●POST /v1/workflows/{id}/runs to start the workflow on a machine_id.
- ●Provide inputs like welcome: true, budget_cents: 500, deadline_seconds: 300.
- ●The server executes steps sequentially, branching with if, looping with loop, and running tasks in parallel with parallel.
- ●Each task step is billed $0.05 per agent step. You pay per step, not per workflow.
- ●Stream events with GET /v1/runs/{id}/events to see progress, states, and errors.
POST /v1/workflows/{id}/runs with inputs to drive a stateful, versioned workflow of tasks, asserts, if, loop, and parallel steps.
Where this beats brittle automation
Traditional automation relies on brittle selectors and hardcoded API calls. When UI changes, selectors break. With the Coasty Workflow DSL, you describe intent, not implementation. Task steps let the agent see the screen and act like a human, handling dynamic layouts, popups, and navigation. Assert steps verify real states, not strings. If and loop steps let you adapt logic at runtime. Parallel steps run independent checks concurrently, reducing total wall-clock time. You pay only for the agent steps that actually execute, not for planning overhead.
Start building multi-step, stateful agents with the Coasty Workflow DSL. Create workflows with task, assert, if, loop, parallel steps, run them with inputs, and stream events. Each task step costs $0.05. Get your API key and build at https://coasty.ai/developers.