What Are Trajectories?
Trajectories are recorded sequences of actions that Cyberdesk captures when your workflow runs successfully. Think of them as “learned paths” through your software—once recorded, they can be replayed deterministically, making subsequent workflow executions much faster and more reliable.A trajectory is essentially a cache of a successful workflow execution, including every action taken, every screen state observed, and every decision made by the AI agent.
How Trajectories Work
1. Initial Run: Recording
When you run a workflow for the first time (or when no matching trajectory exists):- Actions taken (click, type, etc.)
- Screen state before each action (pre-check snapshot)
- Agent’s thought process for each step
- Final results and observations
- Display dimensions (screen resolution)
- Input values used during the original run
2. Subsequent Runs: Replay with Validation
When you run the same workflow again, Cyberdesk attempts to replay the trajectory:- Load: System loads all approved trajectories for this workflow and resolution
- Filter: Filters trajectories that match the current step sequence
- Compare: For each step, compares current screen against cached screenshot
- Decision: AI determines if screens match well enough to proceed
- Replay: If match, executes the cached action
- Fallback: If no match, falls back to agent for that step
- Cache Hit: Workflow completes in seconds (no AI reasoning needed)
- Cache Miss: Falls back to AI agent for that step, records new trajectory from that point
The Approval Process
Why Approval is Required
Trajectories capture exact coordinates, keyboard inputs, and action sequences. Before allowing automatic replay:- Verify Correctness: Ensure the recorded actions actually worked
- Check for Errors: Confirm no mistakes were captured in the trajectory
- Review Observations: Validate that focused actions extracted correct data
- Inspect Coordinates: Ensure clicks hit the right UI elements
How to Approve Trajectories
In the Dashboard:- Navigate to Workflows → Select your workflow
- Click the Trajectories tab
- Review the trajectory:
- Check each step’s screenshot and action
- Verify focused action observations
- Inspect coordinates and inputs
- Click the Approval toggle or checkbox
- Trajectory is now available for future runs
Editing Trajectories
You can edit trajectories in the dashboard to fix coordinates, update observations, or refine cache detection.What You Can Edit
Step Actions:- Coordinates for clicks and drags
- Text to type
- Scroll amounts
- Screenshot zoom areas
- Custom cache detection instructions
- Expected screen states
- Extracted data and observations
- Runtime variable assignments
How to Edit
- Open a trajectory in the trajectory viewer
- Expand the step you want to edit
- Click the edit icon on specific fields
- Make your changes
- Save the trajectory
Editing Focused Actions: Critical Workflow Update
Why This Matters
When a cache miss occurs, the system falls back to running the AI agent using your workflow’s main prompt. If the trajectory has diverged from the prompt, you’ll get inconsistent behavior: Scenario:- Trajectory:
focused_actionextracts “patient_mrn, date_of_birth, primary_diagnosis” - Workflow Prompt: Says to extract “patient_mrn and date_of_birth” only
- Cache Hit: Works perfectly (uses trajectory)
- Cache Miss: Falls back to prompt, extracts different fields, causes output schema mismatch
The Right Approach
When editing focused actions in trajectories:-
Edit the Trajectory:
- Update the focused action instruction
- Modify the expected observation
- Adjust runtime variables if needed
-
Edit the Workflow Prompt:
- Update the same focused_action instruction in the main prompt
- Ensure consistency between trajectory and prompt
- Test with cache disabled to verify prompt works
-
Test Both Paths:
- Run with cache hit (uses trajectory)
- Run with cache disabled (uses prompt)
- Verify both produce same results
Cache Detection: Enabling and Disabling
Cache detection is always active by default, but you have control over it per workflow run.When Cache Detection is Active (Default)
Every workflow run attempts to use approved trajectories:- ⚡ Massive speed improvements (cache hits complete instantly)
- 🎯 Consistent execution (same actions every time)
Disabling Cache Detection
You can disable cache detection for runs by unapproving all approved trajectories in the dashboard. Use Cases for Disabling:- Testing workflow prompt changes
- Debugging trajectory mismatches
- Verifying prompt works without cache
- Development and testing
- Cache detection re-enables automatically for subsequent runs
- Per-run control means you can selectively test without cache
Custom Cache Detection Instructions
To improve cache hit rates and reduce false negatives/positives, you can add Custom Cache Detection Instructions to trajectory steps.What They Do
Custom instructions guide the cache validation AI by providing human context:Where to Add Them
- Open a trajectory in the trajectory viewer
- Expand a step to view details
- Find “Custom Cache Detection Instructions” in the Pre-check Snapshot
- Add your guidance
- Save changes
When to Use Them
Add custom instructions when:- ✅ A step frequently has false cache misses due to minor differences
- ✅ Dynamic content (timestamps, IDs) causes unnecessary validation failures
- ✅ Specific UI elements are critical while others are cosmetic
- ✅ You need to specify tolerances for acceptable variations
- ✅ Recovery agent needs context about validation criteria
Impact on Cache Hit Rates
Well-written custom instructions can:- Increase cache hit rates by 20-40%
- Reduce false negatives (rejecting valid matches)
- Improve recovery agent performance
- Provide valuable context for debugging
Trajectory Lifecycle
Phase 1: Creation
- Workflow runs with AI agent
- Actions recorded in real-time
- Trajectory saved to database
- Status: Unapproved, not used yet
Phase 2: Review
- View trajectory in dashboard
- Inspect each step and screenshot
- Verify focused action observations
- Check coordinates and inputs
Phase 3: Approval
- Approve if trajectory is correct
- Status: Approved, ready for use
Phase 4: Usage
- Future runs load this trajectory
- Each step validated before replay
- Cache hits = fast execution
- Cache misses = fallback to agent
Phase 5: Maintenance
- Edit as needed (coordinates, instructions)
- Update workflow prompt if editing focused actions
- Test with cache disabled after significant changes
- Unapprove if major edits needed, re-approve after testing
Multiple Trajectories Per Workflow
A single workflow can have multiple approved trajectories: Why Multiple Trajectories?- Different Input Patterns: Trajectory for “new patient” vs “existing patient”
- UI Variations: Trajectory for each possible screen layout
- Resolution Differences: Trajectory for 1920x1080 vs 1280x720
- Branching Paths: Different trajectories for different workflow branches
- System loads all approved trajectories for this workflow
- Filters by display resolution (must match exactly)
- For each trajectory, validates screen state at first step
- Selects the trajectory with the best match
- Replays selected trajectory step by step
- Falls back to agent if no trajectory matches
- Multiple trajectories validated simultaneously
- Fast selection even with dozens of trajectories
- Most recent trajectories prioritized
Best Practices
1. Approve Promptly
2. Keep Prompts in Sync
When editing trajectories (especially focused actions), update the workflow prompt to match:3. Use Custom Instructions Strategically
Add custom instructions to steps that:- Frequently fail validation unnecessarily
- Have dynamic content that’s acceptable to ignore
- Require nuanced validation logic
4. Test Before Approving
Run the workflow at least once successfully before approving the trajectory:- Verify all actions completed correctly
- Check output data matches expectations
- Ensure focused actions extracted correct values
- Inspect coordinates hit the right UI elements
5. Maintain Trajectory Hygiene
- Unapprove trajectories that are outdated or incorrect
- Delete trajectories that are no longer relevant
- Edit trajectories when UI changes are minor (coordinate adjustments)
- Re-record when UI changes are major (new flow needed)
6. Monitor Cache Hit Rates
Track your workflow’s cache hit rate in the dashboard:- High hit rate (>80%) = well-optimized trajectories
- Low hit rate (<50%) = may need custom instructions or prompt updates
- Check which steps frequently miss cache
7. Consider Resolution
Trajectories are resolution-specific:- Record trajectories at your most common resolution
- If you use multiple resolutions, you’ll need multiple trajectories
- Display dimensions must match exactly for replay
Common Scenarios
Scenario 1: UI Element Moved
Problem: Button moved from (850, 450) to (850, 480) Solution:- Open trajectory in viewer
- Find the click step
- Edit coordinates from (850, 450) to (850, 480)
- Save trajectory
- Test with cache enabled
Scenario 2: Focused Action Needs More Data
Problem: Trajectory extracts “customer_id” but you now need “customer_id and email” Solution:- Edit trajectory focused_action observation to include email
- IMPORTANT: Update workflow prompt to match:
- Test with cache disabled to verify prompt works
- Test with cache enabled to verify trajectory works
- Re-approve if unapproved
Scenario 3: Dynamic Content Causes False Misses
Problem: Cache detection fails because timestamps/IDs differ Solution:- Open trajectory step
- Add custom cache detection instruction:
- Save trajectory
- Future runs will ignore order ID differences
Scenario 4: Workflow Prompt Changed Significantly
Problem: You updated the workflow prompt with new steps or different logic Solution:- Unapprove all existing trajectories (they’re now outdated)
- Run workflow with cache disabled (force fresh recording)
- Review new trajectory
- Approve new trajectory
- Old trajectories can be deleted or kept for reference
Scenario 5: Want to Test Without Cache
Problem: Need to verify prompt works independently of cache Solution:- Trigger run with cache detection disabled
- Agent executes from scratch using workflow prompt
- New trajectory is recorded (if successful)
- Review and approve new trajectory if it’s better
Trajectory Data Structure
High-Level Structure
Pre-Check Snapshot
Captured before each action:Focused Action Steps
Special handling for dynamic observations:Performance Benefits
Without Trajectories (Every Run Uses AI)
With Trajectories (Cache Hits)
Partial Cache Hits
Even partial cache hits provide benefits:Trajectory Strategies
Strategy 1: Single Golden Trajectory
Approach: One approved trajectory per workflow Best For:- Highly deterministic workflows
- Consistent UI layouts
- Same input pattern every time
- Minimal variation between runs
Strategy 2: Multi-Path Trajectories
Approach: Multiple approved trajectories for different scenarios Best For:- Workflows with branching logic
- Different input patterns (new vs existing records)
- UI variations (different screen layouts)
- Different resolution targets
Strategy 3: Progressive Refinement
Approach: Start with one trajectory, add more as variations are discovered Best For:- New workflows where patterns emerge over time
- Workflows with occasional edge cases
- Gradual optimization
- Approve first successful trajectory
- Monitor cache miss patterns
- Identify common variations
- Record and approve trajectories for those variations
- Cache hit rate improves over time
Troubleshooting
Low Cache Hit Rate
Symptoms: Most runs fall back to agent instead of using cache Possible Causes:- No approved trajectories
- Custom instructions too strict
- UI changed since trajectory was recorded
- Resolution mismatch
- Input patterns vary significantly
- Approve successful trajectories
- Add custom instructions to tolerate minor differences
- Re-record trajectories after UI changes
- Ensure consistent display resolution
- Consider multiple trajectories for different input patterns
Trajectory Approval Uncertainty
Question: “Should I approve this trajectory?” Checklist:- ✅ Workflow completed successfully
- ✅ Output data is correct
- ✅ Focused actions extracted expected values
- ✅ All clicks hit the right UI elements
- ✅ No errors in the run logs
- ✅ Screenshots show correct screens at each step
If any concern → Review more carefully or run again to verify
Trajectory Editing vs Re-Recording
Edit Trajectory When:- Minor coordinate adjustments (button moved slightly)
- Updating custom cache detection instructions
- Refining focused action observations (if prompt also updated)
- Small corrections that don’t change workflow logic
- Major UI redesign
- Workflow prompt changed significantly
- Different action sequence needed
- New steps added or removed
- Complete workflow refactor
Advanced Topics
Parameterized Trajectories
Trajectories can be parameterized to handle variations: Original Input Values:Trajectory Versioning
Trajectories are immutable once approved:- Edits create new versions (updated_at timestamp changes)
- Old trajectory data is overwritten (not versioned separately)
- Consider unapproving before major edits
Resolution Filtering
Trajectories are automatically filtered by display resolution:- Exact Match Required: 1920x1080 trajectory won’t work on 1280x720
- Why: Coordinates are absolute pixel positions
- Solution: Record trajectories at each resolution you use
Summary
Trajectories are Cyberdesk’s intelligent caching system that dramatically speeds up workflow execution:- Recording: Automatic during initial runs
- Approval: Required before trajectories can be used
- Validation: AI compares screen states before each replay
- Editing: Supported, but keep prompts in sync (especially for focused actions)
- Custom Instructions: Enhance cache detection accuracy
- Cache Control: Enable/disable per run as needed