The Workflow DSL Explained: Task, Assert, If, Loop, Parallel
Most automation scripts grow into fragile spaghetti. You repeat the same checks, retry with magic numbers, and hard-code selectors that break on the next release. The Coasty workflow DSL solves this by letting you define a versioned JSON program for your agent. You can orchestrate real desktop tasks, embed assertions that enforce invariants, branch with if conditions, repeat with loop, or run parallel tasks. The DSL lives at POST /v1/workflows, and each task step costs $0.05. Deploy a single workflow that your agent follows end to end, and you get reproducibility, observability, and the ability to pause or resume runs.
How the workflow DSL works
You POST a versioned JSON object to /v1/workflows. The spec defines a sequence of steps, each with a type and required fields. Step types include task, assert, if, loop, parallel, human_approval, retry, succeed, and fail. Variables follow the double-brace syntax {{ inputs.x }} or the stepId.field form. Hard guards such as budget_cents, max_iterations, and deadline_seconds enforce limits. When you start a workflow run, the server evaluates steps in order, tracks variables, and stops on fail or succeed. Task steps bill at $0.05 per step. You can start ad-hoc runs with POST /v1/workflows/runs or create a reusable workflow with POST /v1/workflows/{id}/runs.
import os
import json
import httpx
COASTY_API_KEY = os.getenv("COASTY_API_KEY")
BASE_URL = "https://coasty.ai/v1"
workflow = {
"name": "checkout_demo",
"version": 1,
"steps": [
{
"id": "login",
"type": "task",
"task": "Log in to the demo app with username {{ inputs.username }} and password {{ inputs.password }}."
},
{
"id": "verify_logged_in",
"type": "assert",
"condition": {
"type": "string_equals",
"field": "inputs.last_message",
"expected": "Welcome back!"
}
},
{
"id": "place_order",
"type": "task",
"task": "Click the 'Add to Cart' button, then click 'Checkout'."
},
{
"id": "if_pay_with_card",
"type": "if",
"condition": {
"type": "variable_true",
"field": "inputs.payment_method"
},
"steps": [
{
"id": "enter_card",
"type": "task",
"task": "Enter the card number and expiry in the payment form."
}
]
},
{
"id": "confirm",
"type": "task",
"task": "Confirm the order and verify the confirmation message."
}
],
"budget_cents": 500,
"max_iterations": 20,
"deadline_seconds": 600
}
response = httpx.post(
f"{BASE_URL}/workflows",
headers={"X-API-Key": COASTY_API_KEY},
json=workflow,
)
response.raise_for_status()
print("Created workflow:", response.json())Task steps
- ●Task steps tell the agent what to do on the desktop or browser.
- ●Each task step costs $0.05 and is billed per agent step.
- ●You can append custom instructions (instructions field) to the base prompt for that step.
- ●The agent uses computer vision to understand the screen and click/type like a human.
- ●You can reference variables from inputs or previous steps with double-brace syntax.
A task step is $0.05 and uses the instructions field to customize the agent's prompt.
Assert steps
- ●Assert steps enforce checks after a task or group of steps.
- ●The condition object supports types such as string_equals and variable_true.
- ●When an assert fails, the workflow execution fails unless you wrap it in a retry or if block.
- ●This gives you built-in validation without brittle UI selectors.
- ●You can reference variables like {{ last_step.field }} to check the result of previous actions.
If, loop, and parallel steps
- ●If steps evaluate a condition and run a subset of steps only when true.
- ●Loop steps repeat a block of steps up to max_iterations times, useful for retries or progressive checks.
- ●Parallel steps allow multiple sub-workflows to run concurrently under a budget.
- ●Hard guards such as budget_cents, max_iterations, and deadline_seconds apply to the whole workflow and can abort early.
- ●You can combine if, loop, and parallel to build complex logic like conditional retries or simultaneous updates.
Where this beats brittle automation
Traditional automation relies on CSS selectors, XPath, or hardcoded IDs. When the UI changes, the script breaks. With the Coasty workflow DSL, the agent reads the screen with computer vision and follows natural language instructions. You describe what to do and what to validate, not how to find a button. This makes your workflows resilient to layout changes, layout shifts, and dynamic content. Because the workflow is versioned JSON, you can trace each run, pause or resume, and even retry from a specific step. The server-side evaluation and hard guards prevent runaway costs and give you a single source of truth for your automation logic.
Use the workflow DSL to orchestrate multi-step agents with task, assert, if, loop, and parallel steps. Start building a versioned automation program today and see how computer use handles real desktops and browsers. Get your API key at https://coasty.ai/developers and begin integrating the Coasty computer use agent into your stack.