Trajectories
Recording and viewing agent conversation trajectories
Trajectory Saving Callback
The TrajectorySaverCallback records complete agent conversations including messages, actions, and screenshots for debugging and analysis.
Callbacks Example
from agent.callbacks import TrajectorySaverCallback
agent = ComputerAgent(
model="anthropic/claude-3-5-sonnet-20241022",
tools=[computer],
callbacks=[
TrajectorySaverCallback(
trajectory_dir="my_trajectories",
save_screenshots=True
)
]
)
Shorthand
agent = ComputerAgent(
model="anthropic/claude-3-5-sonnet-20241022",
trajectory_dir="trajectories", # Auto-save trajectories
tools=[computer]
)
View Trajectories Online
View trajectories in the browser at: trycua.com/trajectory-viewer
The viewer provides:
- Interactive conversation replay
- Screenshot galleries
- No data collection
Trajectory Structure
Trajectories are saved with:
- Complete conversation history
- Usage statistics and costs
- Timestamps and metadata
- Screenshots and computer actions
Each trajectory contains:
- metadata.json: Run info, timestamps, usage stats (
total_tokens
,response_cost
) - turn_000/: Turn-by-turn conversation history (api calls, responses, computer calls, screenshots)