For an introduction to trajectories and how they work, see Trajectories 101. This page focuses specifically on custom cache detection instructions that improve trajectory validation accuracy.
The Problem
During trajectory replay, the system compares current screen states against cached screenshots to determine if it can safely reuse recorded actions. However, the default cache detection logic might not always know:- Which UI elements are critical vs. cosmetic for a specific step
- What minor differences are acceptable (e.g., timestamps, dynamic content)
- Special conditions that should invalidate the cache
- Context about why a particular screen state was captured
- Reject valid matches due to irrelevant differences (false negatives)
- Accept invalid matches by missing critical changes (false positives)
- Require human review to understand failures
The Solution
Custom Cache Detection Instructions let you add step-specific notes that guide the cache validation process. These instructions are:- Step-specific: Each trajectory step can have its own custom instructions
- Human-written: Provide context that automated systems can’t infer
- Integrated: Automatically included in cache comparison prompts
- Recovery-aware: Passed to the recovery agent when cache misses occur
How It Works
During Cache Detection
When comparing screen states, the system incorporates your custom instructions into the validation prompt:- Capture: System takes a screenshot of the current state
- Compare: Compares against the cached screenshot from the trajectory
- Custom Context: Your instructions are added to the comparison prompt with high priority
- Decision: The system evaluates whether states match, guided by your instructions
During Agent Recovery
When cache detection fails and the agent takes over:- Context Extraction: System retrieves custom instructions from recent steps
- Priority Messaging: Instructions are highlighted as “CRITICAL” in the recovery prompt
- Guided Recovery: The agent uses your instructions to understand validation criteria
- Informed Actions: Agent makes decisions aware of what you considered important
In the Trajectory Editor
You can add or edit custom instructions in the trajectory viewer:- Navigate to a trajectory in the Workflows section
- Expand any step to view details
- Find the “Custom Cache Detection Instructions” field in the Pre-check Snapshot
- Add your instructions (with helpful tooltip guidance)
- Save changes to update the trajectory
Example Use Cases
Highlighting Critical Elements
Specifying Tolerances
Defining Focus Areas
Conditional Validation
Structural Requirements
Best Practices
Be Specific About Intent
Good: “The confirmation dialog must be visible with the text ‘Are you sure?’” Less Good: “Check the dialog”Focus on Structure Over Content
Good: “Three buttons arranged horizontally at the bottom” Less Good: “Check the buttons are correct”Consider Parameter Variations
Good: “The username field should contain parameter value. Ignore the specific name shown.” Less Good: “Username should be John”Identify Acceptable Differences
Good: “Timestamps and ‘Last Updated’ labels will differ - ignore these” Less Good: Don’t mention what to ignore at allProvide Decision Criteria
Good: “If error banner is visible, cache is invalid. If form is clean, cache is valid.” Less Good: “Something might be wrong”Keep It Concise
Aim for 1-3 sentences that capture the essential validation logic. The system still has the agent’s thought context and other signals.When to Use Custom Instructions
Consider adding custom instructions when:- A step frequently has false positives or negatives
- The validation criteria are subtle or nuanced
- Dynamic content makes comparison challenging
- You’ve observed specific failure patterns
- The step is critical to workflow success
Technical Details
Data Storage
Custom instructions are stored in thepre_check_snapshot object of each trajectory step:
Integration Points
- Cache Comparison: Included in system prompt with “IMPORTANT” prefix
- Engine Propagation: Carried forward when falling back from cache to agent
- Tool Execution: Available as
cached_custom_instructionskwarg - Agent Recovery: Highlighted in recovery message with 🎯 emoji for visibility