> ## Documentation Index
> Fetch the complete documentation index at: https://piyushvyas.mintlify.site/llms.txt
> Use this file to discover all available pages before exploring further.

# Tracing

> View, filter, replay, and export session traces for debugging and analysis.

# Tracing

BAP automatically records NDJSON traces for every session to `~/.bap/traces/`. The `bap trace` command lets you view, filter, replay, and export these traces.

## View Recent Traces

```bash theme={null}
bap trace                    # Last 10 steps from most recent session
bap trace --limit=20         # Last 20 steps
bap trace --all              # All steps
```

## List Sessions

```bash theme={null}
bap trace --sessions
```

Shows all recorded trace sessions with timestamps and step counts.

## Filter by Session

```bash theme={null}
bap trace --session=cli-9222
```

<ParamField path="--session" type="string">
  Show traces for a specific session ID.
</ParamField>

<ParamField path="--limit" type="number" default="10">
  Number of trace entries to show.
</ParamField>

<ParamField path="--all" type="flag">
  Show all trace entries instead of the default last 10.
</ParamField>

<ParamField path="--sessions" type="flag">
  List all recorded trace sessions.
</ParamField>

## Replay as HTML Timeline

Generate a self-contained HTML timeline viewer:

```bash theme={null}
bap trace --replay
```

Opens an interactive timeline showing every request with timing, status, and result summary. The HTML file is self-contained -- no external dependencies.

<ParamField path="--replay" type="flag">
  Generate a self-contained HTML timeline viewer and save it to the current directory.
</ParamField>

## Export as JSON

```bash theme={null}
bap trace --export
bap trace --export=my-traces.json
```

<ParamField path="--export" type="string">
  Export traces as JSON. Optionally provide a filename.
</ParamField>

## Trace Data

Each trace entry includes:

* **Method** -- The BAP protocol method called (e.g., `page/navigate`, `agent/act`)
* **Timing** -- Request start time and duration in milliseconds
* **Status** -- Success or error
* **Result summary** -- Condensed result data

<Tip>
  Use `bap trace` to debug failures. Every BAP command is recorded with timing and result data,
  making it easy to identify what went wrong and when.
</Tip>
