Back to Blog
Engineering

Rachel Kim7 min
Alt+F4

Most browser automation tools rely on brittle selectors and static APIs. When a UI changes, scripts break. The workflow DSL solves this by letting you orchestrate a computer use agent through a versioned JSON DSL. You can define tasks, verify results, branch logic, loop, and run steps in parallel, all backed by real desktop environments driven by the Coasty Computer Use API.

What the workflow DSL is

  • A versioned JSON format that describes a sequence of runs.
  • POST /v1/workflows creates a reusable workflow definition.
  • POST /v1/workflows/{id}/runs executes a workflow instance.
  • POST /v1/workflows/runs supports ad-hoc inline workflows.
  • Task steps are billed at $0.05 per agent step.
  • Hard guards include budget_cents, max_iterations, and deadline_seconds.
  • State is tracked across steps using variables like {{inputs.x}} and stepId.field.
python
import os
import json
import requests

COASTY_API_KEY = os.getenv("COASTY_API_KEY")
BASE_URL = "https://coasty.ai/v1"

# Simple workflow: a task, an assert, a loop, and a parallel set of tasks
workflow = {
  "version": "1",
  "steps": [
    {
      "id": "login",
      "type": "task",
      "task": "Log in to https://example.com/login with email "
              "{{inputs.email}} and password {{inputs.password}}"
    },
    {
      "id": "verify_logged_in",
      "type": "assert",
      "condition": {
        "type": "contains",
        "subject": {
          "stepId": "login",
          "field": "status"
        },
        "value": "succeeded"
      }
    },
    {
      "id": "fetch_items",
      "type": "task",
      "task": "Navigate to https://example.com/items and extract the"
              " list of item names into stepId.field items"
    },
    {
      "id": "process_items_loop",
      "type": "loop",
      "condition": {
        "type": "has_next",
        "source": {
          "stepId": "fetch_items",
          "field": "items"
        }
      },
      "body": {
        "steps": [
          {
            "id": "process_item",
            "type": "task",
            "task": "Click on the first item in the list, open its details page,"
                    " and fill in a note with {{inputs.note}}",
            "for_each": {
              "stepId": "fetch_items",
              "field": "items"
            }
          }
        ]
      },
      "max_iterations": 20
    },
    {
      "id": "parallel_tasks",
      "type": "parallel",
      "steps": [
        {
          "id": "task_a",
          "type": "task",
          "task": "Search on https://example.com/search for "
                  "{{inputs.search_query}} and save results"
        },
        {
          "id": "task_b",
          "type": "task",
          "task": "Open https://example.com/settings and update timezone"
                  " to {{inputs.timezone}}"
        }
      ]
    }
  ],
  "hard_guards": {
    "budget_cents": 500,
    "max_iterations": 50,
    "deadline_seconds": 600
  }
}

# Create the workflow
headers = {
    "Authorization": f"Bearer {COASTY_API_KEY}",
    "Content-Type": "application/json"
}
resp = requests.post(f"{BASE_URL}/workflows", json=workflow, headers=headers)
resp.raise_for_status()
workflow_id = resp.json()["id"]
print("Created workflow", workflow_id)

# Run the workflow
run_params = {
    "inputs": {
        "email": "[email protected]",
        "password": "secret",
        "note": "Review item",
        "search_query": "automation tools",
        "timezone": "America/New_York"
    },
    "cua_version": "v4"
}
resp = requests.post(f"{BASE_URL}/workflows/{workflow_id}/runs",
                     json=run_params, headers=headers)
resp.raise_for_status()
run_id = resp.json()["id"]
print("Started run", run_id)

Step types in detail

  • "task" runs a computer use agent to perform an instruction. Each task step is billed at $0.05 per agent step.
  • "assert" evaluates a condition against the result of a previous step (e.g., stepId.field) and fails the workflow if false.
  • "if" branches execution based on a boolean condition referencing a step field.
  • "loop" iterates over a source array field (stepId.field) and repeats a body sequence, with max_iterations guard.
  • "parallel" runs multiple steps concurrently and waits for all to complete before continuing.
  • "human_approval" pauses execution, waiting for an external approval signal to resume.
  • "retry" re-runs a task if it fails, optionally with an exponential backoff.
  • "succeed" and "fail" explicitly finish the workflow with success or failure.

Variables and refs

  • Input data uses double-brace syntax like {{inputs.email}}.
  • Step results are referenced as stepId.field (e.g., "login.status").
  • Condition objects use structured fields like type, subject, value.
  • Loop bodies use for_each to bind each list item to a variable.
  • Hard guards apply to the whole workflow: budget_cents, max_iterations, deadline_seconds.

Use stepId.field refs instead of brittle XPaths to read the current state of your agent.

Where this beats brittle automation

  • The computer use agent sees the live UI, so you do not need to maintain selectors.
  • Assertions verify actual outcomes, not just API responses.
  • Loops adapt to dynamic lists, while parallel steps save time on independent actions.
  • Hard guards protect you from runaway costs and timeouts.
  • The DSL is versioned and reusable, letting you share workflows across teams.

You can now compose resilient automation workflows with tasks, asserts, conditionals, loops, and parallelism. The DSL gives you a single source of truth for complex agent behaviors. To get started, register for an API key at https://coasty.ai/developers and build your first workflow DSL.

© 2026 Coasty

Backed byYCombinator