|
| 1 | +# Agent Traces |
| 2 | + |
| 3 | +<div class="flex justify-center"> |
| 4 | +<img class="block dark:hidden" src="https://huggingface.co/datasets/huggingface/documentation-images/resolve/main/datasets/agent-traces-preview-light.webp" alt="Agent trace preview on a dataset page in light mode."/> |
| 5 | +<img class="hidden dark:block" src="https://huggingface.co/datasets/huggingface/documentation-images/resolve/main/datasets/agent-traces-preview-dark.webp" alt="Agent trace preview on a dataset page in dark mode."/> |
| 6 | +</div> |
| 7 | + |
| 8 | +Agent traces from Claude Code, Codex, and Pi Agent are natively supported on the Hugging Face Hub. Upload the raw JSONL sessions to a [Dataset](https://huggingface.co/datasets?format=format%3Aagent-traces) or a [Storage Bucket](./storage-buckets) to open them in a dedicated trace viewer. Datasets show traces in Data Studio; buckets let you open individual `.jsonl` files directly. |
| 9 | + |
| 10 | +## Find your traces |
| 11 | + |
| 12 | +Each supported agent writes JSONL sessions to the following directories: |
| 13 | + |
| 14 | +| Agent | Local session directory | |
| 15 | +| ----------- | ----------------------- | |
| 16 | +| Claude Code | `~/.claude/projects` | |
| 17 | +| Codex | `~/.codex/sessions` | |
| 18 | +| Pi | `~/.pi/agent/sessions` | |
| 19 | + |
| 20 | +These trace files are supported out of the box, so you can upload them without modifying or converting them first. |
| 21 | + |
| 22 | +Trace files can include prompts, tool inputs, command output, local paths, screenshots, secrets, private code, and personal data. Review and redact traces before publishing them publicly, or keep the dataset or bucket private if you are not sure what is inside. |
| 23 | + |
| 24 | +For Pi Agent sessions, [`pi-share-hf`](https://github.com/badlogic/pi-share-hf) can help collect project sessions, redact known secrets, run TruffleHog and LLM review, and upload only sessions that pass checks. |
| 25 | + |
| 26 | +<Tip> |
| 27 | + |
| 28 | +The easiest way to upload is to ask your agent itself: point it at the directory above and tell it to upload the `.jsonl` files to a Hub dataset or bucket. |
| 29 | + |
| 30 | +Buckets are especially useful if you want to keep syncing traces as new sessions land. |
| 31 | + |
| 32 | +</Tip> |
| 33 | + |
| 34 | +## Upload your traces |
| 35 | + |
| 36 | +After creating a dataset or bucket, install the `hf` CLI with the [recommended standalone installer](/docs/huggingface_hub/guides/cli#getting-started) and log in. If you want your coding agent to run `hf` commands for you, install the Hugging Face CLI skill with `hf skills add`. |
| 37 | + |
| 38 | +```bash |
| 39 | +curl -LsSf https://hf.co/cli/install.sh | bash |
| 40 | +hf auth login |
| 41 | +hf skills add |
| 42 | + |
| 43 | +hf upload <username>/<dataset-name> ~/.codex/sessions . --repo-type dataset |
| 44 | +hf buckets sync ~/.codex/sessions hf://buckets/<username>/<bucket-name>/codex |
| 45 | +``` |
| 46 | + |
| 47 | +Replace `~/.codex/sessions` with the matching session directory for your agent. Use `hf upload` for datasets and `hf buckets sync` for buckets you want to update as new traces are written. The shorter `hf sync` command is an alias for `hf buckets sync`. |
| 48 | + |
| 49 | +## View your traces |
| 50 | + |
| 51 | +Once you have traces in a dataset, open Data Studio and click a row. For traces in a Storage Bucket, navigate to the `.jsonl` file you want to inspect and open it. The trace viewer shows the session timeline, prompts, assistant messages, tool calls, and results. |
| 52 | + |
| 53 | +<div class="flex justify-center"> |
| 54 | +<img src="https://huggingface.co/datasets/huggingface/documentation-images/resolve/main/datasets/agent-traces-session.webp" alt="Agent trace session viewer showing user and assistant turns with expanded tool calls."/> |
| 55 | +</div> |
| 56 | + |
| 57 | +For a public example, open [`TeichAI/DeepSeek-v4-Pro-Agent`](https://huggingface.co/datasets/TeichAI/DeepSeek-v4-Pro-Agent). You can also browse more datasets tagged as [`traces`](https://huggingface.co/datasets?format=format%3Aagent-traces). |
0 commit comments