Skip to main content
bap run is the optimized path for executing workflows. It compiles workflow YAML into an execution plan that batches consecutive actions, applies fusion flags, and leverages the action cache for instant replay.

How It Works

1

Compile

The workflow compiler reads the YAML, expands macros, substitutes parameters, and groups consecutive action steps into batched server calls.
2

Batch

Consecutive batchable actions (click, fill, type, press, select, check, uncheck, hover, scroll) are merged into a single fused-act server call. Non-batchable steps (goto, observe, extract, screenshot, wait) create batch boundaries.
3

Fuse

The compiler sets fusion flags on batches: - First action batch after a navigate gets preObserve: true - Last action batch before a navigate/extract gets postObserve: true - Intermediate observe batches get responseTier: "minimal"
4

Execute

Batches are executed sequentially against the BAP server. Cache hits skip DOM traversal entirely.

Usage

Execution Plan

The compiler produces an ExecutionPlan with batched steps:

Batch Types

Dry Run

Preview what the compiler produces without executing anything:
This outputs:
  • The number of original steps vs compiled batches
  • Each batch with its type, steps, and fusion flags
  • The estimated call reduction percentage
  • Cache warmth status (how many selectors are already cached)

Cache Warming

After a successful workflow run, BAP saves a cache manifest at ~/.bap/cache/workflows/<name>.json. The manifest tracks:
  • Workflow hash — SHA256 of the YAML content (invalidates on change)
  • Cache keys — Action cache entries used during the run
  • Selector map — Resolved selector mappings for fast replay
  • Batch timings — Duration per batch for performance tracking

Checking cache warmth

Forcing a warm-up

This executes the workflow once to populate the action cache, then the next bap run will hit cached selectors and skip DOM traversal.

Compiler Details

Macro Expansion

Macros are expanded before batching. The compiler supports up to 10 expansion passes for nested macros and detects circular references:
The three macro steps are inlined and batched into a single fused-act call.

Repeat Expansion

Numeric repeat: N is expanded at compile time by duplicating the step N times. Conditional repeat: { until: ... } is preserved as a conditional batch for runtime evaluation.

Parameter Substitution

All {{param}} placeholders in step args and label fields are substituted with merged params (workflow defaults + runtime overrides) before batching.

Workflow vs Run

Use bap workflow run for debugging and bap run for production. The workflow runner executes steps one at a time, making it easier to identify which step failed. The optimized runner batches steps, which is faster but harder to debug.