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
Compile
The workflow compiler reads the YAML, expands macros, substitutes parameters, and groups consecutive action steps into batched server calls.
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.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"Usage
Execution Plan
The compiler produces anExecutionPlan with batched steps:
Batch Types
| Type | Description |
|---|---|
fused-act | Multiple action steps executed as a single agent/act call |
navigate | A goto step |
observe | An observe step |
extract | An extract step |
screenshot | A screenshot step |
wait | A wait step |
conditional | A step with repeat: { until: ... } |
Dry Run
Preview what the compiler produces without executing anything:- 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
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:fused-act call.
Repeat Expansion
Numericrepeat: 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
| Command | What it does |
|---|---|
bap workflow run <name> | Sequential execution, no compilation, no batching |
bap run <name> | Compiled execution with batching, fusion, and caching |