role:button:"Submit" to a concrete CSS selector like #submit-btn, it caches that mapping for future use.
How It Works
~/.bap/cache/actions/. Each entry is a JSON file named by its SHA256 key.
Cache Key
Keys are generated from three components:
This means the same selector on different sites gets different cache entries, and the same selector with different actions (click vs hover) is also cached separately.
What Gets Cached
The cache stores resolved CSS selectors, not the original semantic selectors:Only elements with an
id or data-testid attribute are cached. This is intentional — these are
the most stable identifiers. Elements without them rely on semantic resolution each time.Cache Entry Structure
Configuration
Invalidation
The cache is invalidated in three ways:1
TTL expiry
Entries older than 24 hours (default) are removed on next access. Expired entries are also cleaned up when the cache loads from disk.
2
Selector failure
If a cached CSS selector fails to match (element was removed or ID changed), the cache entry is
deleted immediately. The server falls back to fresh semantic resolution.
3
LRU eviction
When the cache exceeds
maxEntries (default 1000), the oldest entry by creation time is evicted.Cache Stats
TheActionCache class exposes a stats() method:
Workflow Integration
The action cache integrates with workflow fusion. After a successfulbap run, a cache manifest is saved that tracks which cache entries were used. This enables:
- Cache warmth checks:
bap run <name> --dry-runreports how many selectors are already cached - Selective invalidation: If the workflow YAML changes (different SHA256), the manifest is regenerated on next run
- Performance tracking: Batch timings are stored in the manifest for trend analysis
Manual Cache Management
The cache lives at~/.bap/cache/actions/ as individual JSON files. To clear it: