Tutorial

Coasty Workflow DSL Explained: Task, Assert, If, Loop, Parallel

Lisa Chen||8 min
+K

Building multi-step automation that must adapt to UI changes is hard with brittle selectors. Coasty's workflow DSL lets you orchestrate complex, stateful pipelines with tasks, asserts, conditional logic, loops, and parallel steps, all without hardcoding element IDs. You define a versioned JSON workflow, POST it to /v1/workflows, and let the server drive completion. Each task step is billed $0.05.

How the workflow DSL works

A workflow is a versioned JSON DSL that the server parses and executes as a series of runs. You POST a workflow definition to POST /v1/workflows. The server returns a workflow ID. You then POST /v1/workflows/{id}/runs to start a run, or POST /v1/workflows/runs for ad-hoc inline runs. Each run is driven by the server via step types: task, assert, if, loop, parallel, human_approval, retry, succeed, fail. Variables can reference inputs ({{inputs.x}}) and step outputs ({{stepId.field}}). You can set hard guards like budget_cents, max_iterations, and deadline_seconds. Each task step is billed $0.05 per agent step.

bash
curl -X POST https://coasty.ai/v1/workflows \
  -H 'Content-Type: application/json' \
  -H 'X-API-Key: $COASTY_API_KEY' \
  -d '{
    "name": "login_and_export",
    "version": "1.0",
    "steps": [
      {
        "type": "task",
        "id": "login",
        "prompt": "Log in using username ${inputs.username} and password ${inputs.password}."
      },
      {
        "type": "assert",
        "id": "assert_logged_in",
        "condition": {
          "field": "status",
          "operator": "eq",
          "value": "logged_in"
        }
      },
      {
        "type": "if",
        "id": "if_export",
        "condition": {
          "field": "assert_logged_in.status",
          "operator": "eq",
          "value": true
        },
        "steps": [
          {
            "type": "task",
            "id": "export",
            "prompt": "Export data to CSV."
          },
          {
            "type": "succeed"
          }
        ],
        "else": {
          "steps": [
            {
              "type": "fail",
              "message": "Login failed."
            }
          ]
        }
      }
    ],
    "max_iterations": 10,
    "deadline_seconds": 300
  }'

Step types in detail

  • task: executes a computer use agent step. Billed $0.05 per agent step. Use prompt to describe what to do on the screen.
  • assert: validates a condition against a field (e.g., status, value) and operator (eq, ne, gt, lt). If false, the server fails the run.
  • if: evaluates a condition using a field from a previous step (e.g., assert.logged_in.status) and operator. Executes the given steps or the else block.
  • loop: repeats steps up to max_iterations or until a condition becomes true. You can define a condition or iteration count.
  • parallel: runs multiple steps concurrently. Useful for launching multiple agent tasks that can run in parallel.
  • human_approval: pauses the workflow and waits for human intervention. Server state becomes awaiting_human.
  • retry: retries a task or block up to a max count with exponential backoff.
  • succeed: marks the workflow as successful. All subsequent steps are skipped.
  • fail: marks the workflow as failed with an optional message. All subsequent steps are skipped.

Each task step is billed $0.05 per agent step.

Where this beats brittle automation

With selectors and XPath, a single UI change can break your automation. Coasty's workflow DSL uses natural language prompts for each task. The server interprets the UI state and acts like a human. Assert steps let you validate outcomes without hardcoding element locations. Conditional if/else blocks adapt to success or failure. Parallel steps let you launch multiple agents at once. You pay only for the agent steps that actually run, not for every possible path.

Start building multi-step, stateful workflows with the Coasty workflow DSL. Define tasks, asserts, if, loop, and parallel steps, POST your workflow to /v1/workflows, and launch runs to automate real desktops and browsers. Get a key at https://coasty.ai/developers.

Want to see this in action?

View Case Studies
Try Coasty Free