---
title: Trajectories
description: 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

```python
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

```python
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:
**[cua.ai/trajectory-viewer](https://cua.ai/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)
