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:| Component | Example |
|---|---|
action | action/click |
urlOrigin | https://example.com |
selectorHint | role:button:"Submit" |
What Gets Cached
The cache stores resolved CSS selectors, not the original semantic selectors:| Resolved to | CSS selector stored |
|---|---|
Element with id | #submit-btn (escaped via CSS.escape()) |
Element with data-testid | [data-testid="submit-button"] |
| Other elements | Not cached (intentional) |
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
| Option | Default | Description |
|---|---|---|
dir | ~/.bap/cache/actions | Cache directory |
enabled | true | Enable/disable caching |
ttl | 86400 (24 hours) | Time-to-live in seconds |
maxEntries | 1000 | Maximum entries before LRU eviction |
Invalidation
The cache is invalidated in three ways: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.
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.
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: