Callbacks
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",
tools=[computer],
trajectory_dir="trajectories" # Auto-adds TrajectorySaverCallback
)
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
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)