You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
@@ -143,6 +143,63 @@ You might wonder: "Isn't 50 elements vs 24,567 elements comparing apples to oran
143
143
144
144
**Future:** OpenClaw may add configuration to set Predicate as the default snapshot provider.
145
145
146
+
---
147
+
148
+
## ⚡ Usage with Autonomous Agents
149
+
150
+
> **Important:** OpenClaw agents work autonomously—they don't wait for manual slash commands. Here's how to integrate Predicate snapshots into autonomous workflows.
151
+
152
+
### Option 1: Include in Task Instructions (Recommended)
153
+
154
+
Add Predicate snapshot instructions directly in your task prompt:
155
+
156
+
```
157
+
Navigate to amazon.com and find the cheapest laptop under $500.
158
+
159
+
IMPORTANT: For page observation, use /predicate-snapshot instead of the
160
+
default accessibility tree. Use /predicate-act to interact with elements
161
+
by their ID from the snapshot.
162
+
```
163
+
164
+
### Option 2: Modify Agent System Prompt
165
+
166
+
For consistent usage across all tasks, add to your agent's system prompt:
167
+
168
+
```
169
+
## Browser Observation
170
+
When observing web pages, always use /predicate-snapshot instead of the
171
+
default accessibility tree. This provides ML-ranked elements optimized
172
+
for efficient decision-making (~500 tokens vs ~18,000 tokens).
173
+
174
+
To interact with page elements:
175
+
1. Call /predicate-snapshot to get ranked elements with IDs
176
+
2. Call /predicate-act <action> <element_id> to perform actions
177
+
```
178
+
179
+
### Option 3: OpenClaw Config (Future)
180
+
181
+
OpenClaw may add support for setting the default snapshot provider:
| File system | Only `./test-output/` is mounted |
322
+
| Credentials | None stored—test site uses fake credentials |
323
+
324
+
**Using docker-compose:**
325
+
326
+
```bash
327
+
docker-compose up skill-test # Skill MCP tools test
328
+
docker-compose up openclaw-test # OpenClaw full runtime test
329
+
docker-compose up demo-login # Login demo
330
+
```
331
+
332
+
The test uses a purpose-built test site (`https://www.localllamaland.com/login`) with fake credentials (`testuser` / `password123`)—no real accounts involved.
333
+
334
+
### Run Demo (Local)
207
335
208
336
Compare token usage between accessibility tree and Predicate snapshot:
209
337
@@ -315,134 +443,62 @@ This demo compares A11y Tree vs Predicate Snapshot across **all 6 steps**, measu
|**Token Savings**| baseline |**70-74% per step**| Significant |
322
-
|**SPA Hydration**| No built-in wait |**`check().eventually()` handles it**| More reliable |
323
-
324
-
**Why A11y Tree Failed at Step 4:**
325
-
326
-
The A11y (accessibility tree) approach failed to click the login button because:
327
-
328
-
1.**Element ID mismatch**: The A11y tree assigns sequential IDs based on DOM traversal order, which can change between snapshots as the SPA re-renders. The LLM selected element 47 ("Sign in"), but that ID no longer pointed to the button after form state changed.
448
+
|**Steps Completed**| 6/6 |**6/6**| Both pass |
449
+
|**Total Tokens**| 5,366 |**1,565**|**-71%**|
450
+
|**Token Savings**| baseline |**67-74% per step**| Significant |
329
451
330
-
2.**No stable identifiers**: Unlike Predicate's `data-predicate-id` attributes (injected by the browser extension), A11y IDs are ephemeral and not anchored to the actual DOM elements.
452
+
**Why Predicate Snapshot is better:**
331
453
332
-
3.**SPA state changes**: After filling both form fields, the button transitioned from disabled → enabled. This state change can cause the A11y tree to re-order elements, invalidating the LLM's element selection.
333
-
334
-
**Predicate Snapshot succeeded because:**
335
-
-`data-predicate-id` attributes are stable across re-renders
336
-
- ML-ranking surfaces the most relevant elements (button with "Sign in" text)
337
-
-`runtime.check().eventually()` properly waits for SPA hydration
454
+
1.**Dramatic token reduction**: 71% fewer tokens across the entire workflow (5,366 → 1,565 tokens)
455
+
2.**ML-ranked elements**: Only the most relevant interactable elements are included with enough context, reducing noise
> **Key Insight:** Predicate Snapshot not only reduces tokens by 70%+ per step, but also **improves automation reliability** on SPAs with automatic wait for hydration via `runtime.check().eventually()`. The stable element IDs survive React/Next.js re-renders that break A11y tree-based approaches.
518
+
> **Key Insight:** Predicate Snapshot reduces tokens by **67-74% per step** while maintaining the same pass rate. For multi-step workflows, this translates to significant cost savings and faster LLM inference.
0 commit comments