Back to Blog
Tutorial

Michael Rodriguez8 min
+Z

Building a single task agent is easy. But real-world workflows are multi-step, conditional, and retryable. You need an orchestration layer that can handle success, failures, human handoffs, and parallel work. The Coasty workflow DSL gives you declarative control over your computer use agent. You define a versioned JSON DSL, POST it to /v1/workflows, and the server runs it as a sequence of task steps, asserts, conditionals, loops, and parallel branches. Each task step costs $0.05, billed per agent step. This post explains every step type and shows you how to wire them together with a working example.

What you get with the workflow DSL

  • A versioned JSON DSL that you POST to /v1/workflows. The DSL is a flexible structure that you can version and re-run.
  • Step types: task, assert, if, loop, parallel, human_approval, retry, succeed, fail. Each represents a specific control flow pattern.
  • Conditional logic with structured conditions. You can branch on success/failure, variable values, or meeting a budget, deadline, or iteration limit.
  • Variables like {inputs.x} and stepId.field. You can reference input parameters and intermediate step outputs.
  • Hard guards: budget_cents, max_iterations, deadline_seconds. The DSL can abort runs that exceed these constraints.
  • Task steps are billed at $0.05 per agent step. This aligns with the per-step cost of task runs.

How it works

You create a workflow DSL with a version and a list of steps. Each step has a type and a set of fields that depend on the type. You POST this DSL to /v1/workflows. The server returns an id. You then POST /v1/workflows/{id}/runs to start execution. The server drives an agent through the steps, tracking state and variables. You can stream events with GET /v1/runs/{id}/events. If a step fails, the DSL can retry, branch, or fail the run. When all steps complete, the run ends with succeeded, failed, or cancelled state. The DSL is declarative, but the agent performs real screen capture, prediction, and clicking actions.

bash
Create a workflow DSL with task, assert, if, loop, and parallel steps. POST to /v1/workflows, start a run, and stream events.

export COASTY_API_KEY=$(cat ~/.coasty_key)

WORKFLOW_DSL=$(cat <<'EOF'
{
  "version": "1",
  "steps": [
    {
      "type": "task",
      "stepId": "open_browser",
      "description": "Open Chrome and navigate to https://example.com",
      "cua_version": "v3"
    },
    {
      "type": "assert",
      "stepId": "page_loaded",
      "condition": {
        "type": "success",
        "on": "open_browser"
      },
      "description": "Verify the browser opened successfully"
    },
    {
      "type": "if",
      "stepId": "check_login",
      "condition": {
        "type": "equal",
        "left": "{inputs.is_logged_in}",
        "right": "false"
      },
      "then": [
        {
          "type": "task",
          "stepId": "login",
          "description": "Log in with credentials",
          "cua_version": "v3"
        }
      ],
      "else": [
        {
          "type": "task",
          "stepId": "skip_login",
          "description": "Skip login",
          "cua_version": "v3"
        }
      ]
    },
    {
      "type": "loop",
      "stepId": "find_item",
      "condition": {
        "type": "not_equal",
        "left": "{inputs.item_found}",
        "right": "true"
      },
      "max_iterations": 5,
      "steps": [
        {
          "type": "task",
          "stepId": "search_item",
          "description": "Search for an item",
          "cua_version": "v3"
        }
      ]
    },
    {
      "type": "parallel",
      "stepId": "parallel_checkout",
      "steps": [
        {
          "type": "task",
          "stepId": "add_to_cart",
          "description": "Add item to cart",
          "cua_version": "v3"
        },
        {
          "type": "task",
          "stepId": "apply_coupon",
          "description": "Apply coupon code",
          "cua_version": "v3"
        }
      ]
    },
    {
      "type": "task",
      "stepId": "complete_checkout",
      "description": "Complete checkout",
      "cua_version": "v3"
    },
    {
      "type": "succeed",
      "stepId": "success",
      "description": "Workflow completed successfully"
    }
  ]
}
EOF
)

# POST workflow DSL
RESPONSE=$(curl -s -X POST https://coasty.ai/v1/workflows \
  -H "X-API-Key: $COASTY_API_KEY" \
  -H "Content-Type: application/json" \
  -d "$WORKFLOW_DSL")

WORKFLOW_ID=$(echo "$RESPONSE" | jq -r '.id')
echo "Workflow created: $WORKFLOW_ID"

# Start a run
RUN_RESPONSE=$(curl -s -X POST "https://coasty.ai/v1/workflows/$WORKFLOW_ID/runs" \
  -H "X-API-Key: $COASTY_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{"inputs": {"is_logged_in": "false", "item_found": "false"}}')

RUN_ID=$(echo "$RUN_RESPONSE" | jq -r '.run.id')
echo "Run started: $RUN_ID"

# Stream events
curl -s -N "https://coasty.ai/v1/runs/$RUN_ID/events" \
  -H "X-API-Key: $COASTY_API_KEY" \
  --no-buffer | jq -r '.event.type.event.step_id.event.status.event.message' | head -20

The workflow DSL lets you orchestrate multi-step computer use agents with declarative steps, conditionals, loops, and parallel branches.

Where this beats brittle automation

Traditional automation relies on brittle selectors like CSS classes, XPath, or IDs that can change at any time. If a UI updates, your script breaks. A computer use agent, orchestrated through the workflow DSL, sees the screen and acts like a human. It captures a screenshot, predicts the next action, and clicks based on visual context. The workflow DSL adds robustness by letting you assert conditions, retry on failure, branch based on state, loop until a condition is met, and run parallel tasks. This means your automation adapts to real UI changes and handles edge cases gracefully, all while staying declarative and versionable.

The Coasty workflow DSL gives you a powerful way to orchestrate computer use agents across browsers, terminals, and desktop apps. You can build multi-step workflows that verify state, retry failures, loop until criteria are met, and run parallel tasks. Each task step is billed at $0.05 per agent step. Ready to build your first workflow? Get your API key at https://coasty.ai/developers.

© 2026 Coasty

Backed byYCombinator