Fast local web viewer for pydantic-ai traces (list[ModelMessage] JSON dumps)
Project description
pydantic-ai-trace
Use pydantic-ai-trace when you need to inspect an agent run from a JSON dump. Give it a pydantic-ai list[ModelMessage] dump and it opens the run in a browser view.
It is a lightweight local tool. Point it at a trace or a directory of traces and it reads the files from disk, reloads them when they change, and exports individual traces as self-contained HTML files. Your traces stay on disk, with no hosted service or account.
What you can inspect
- The full request and response sequence, including prompts, text, thinking, tool calls, tool results, and unknown parts
- Tool calls paired with their results, including results in later messages
- Model, provider, timing, and token usage
- A searchable directory tree for
.jsonand.jsonltraces - Collapsible large values, rendered Markdown, and keyboard navigation
Run from a checkout
This project uses pixi. Build the bundled frontend once, then run paitrace with a trace file or directory.
pixi run build-frontend
pixi run paitrace trace.json
Usage
# View one trace
pixi run paitrace trace.json
# Browse a directory tree of traces
pixi run paitrace ./my-traces/
# Write one trace to a standalone HTML file
pixi run paitrace export trace.json -o trace.html
# Choose a trace line when exporting a multi-trace JSONL file
pixi run paitrace export runs.jsonl --line 2
The viewer binds to 127.0.0.1:1205 and opens your browser. Pass --port, --host, or --no-open to change that behavior.
Trace files
The viewer reads the JSON emitted by ModelMessagesTypeAdapter.dump_json(messages):
.json: one bare JSON array ofModelMessageobjects.jsonl: one such array per line
When you open a directory, each line in a multi-trace .jsonl file is available as a separate trace.
Development
Run the API and frontend in separate terminals while working on the viewer.
pixi run dev-api ./trace.json # API with reload on port 1205
pixi run dev-web # Vite with HMR, proxying /api
pixi run test # pytest and vitest
pixi run lint # ruff, prettier, and eslint
pixi run typecheck # pyright and TypeScript
pixi run build # bundled frontend plus sdist and wheel
Releasing
Push a vX.Y.Z tag. The package version is derived from that tag, so no source file needs a
version bump. GitHub Actions runs the full check suite, builds the frontend into the wheel and
source distribution, publishes both to PyPI using trusted publishing, and creates a GitHub
release. Configure a pypi environment in GitHub and add this repository as a trusted publisher
for the pydantic-ai-trace project on PyPI before the first release.
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file pydantic_ai_trace-0.1.0.tar.gz.
File metadata
- Download URL: pydantic_ai_trace-0.1.0.tar.gz
- Upload date:
- Size: 171.6 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.12.9
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
57746661af2ce616c50457f5de01b1b6f66a2230d000c3e04b495ecae17684f0
|
|
| MD5 |
57b4a0a9dbf80149c5b7be86105eaab7
|
|
| BLAKE2b-256 |
397472864d4928eea03e5ec83b1a5a9982b03228f4ab18809e0be2bce8049dd7
|
Provenance
The following attestation bundles were made for pydantic_ai_trace-0.1.0.tar.gz:
Publisher:
release.yml on moritzwilksch/pydantic-ai-trace
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
pydantic_ai_trace-0.1.0.tar.gz -
Subject digest:
57746661af2ce616c50457f5de01b1b6f66a2230d000c3e04b495ecae17684f0 - Sigstore transparency entry: 2166937149
- Sigstore integration time:
-
Permalink:
moritzwilksch/pydantic-ai-trace@4e17ae81bda4a6f58e1c7b2dab0bb24a7931b424 -
Branch / Tag:
refs/tags/v0.1.0 - Owner: https://github.com/moritzwilksch
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
release.yml@4e17ae81bda4a6f58e1c7b2dab0bb24a7931b424 -
Trigger Event:
push
-
Statement type:
File details
Details for the file pydantic_ai_trace-0.1.0-py3-none-any.whl.
File metadata
- Download URL: pydantic_ai_trace-0.1.0-py3-none-any.whl
- Upload date:
- Size: 71.7 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.12.9
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
99aece16fb19a715c89ed1c070f6f3e8e39f1875df06c12da0909985fd054136
|
|
| MD5 |
d7b9b0957a4dd789fc5d8077125de8fd
|
|
| BLAKE2b-256 |
193bf6241275035849ebcba55e6a908ad3f2f6dd9f86c81a624857e9d6d33f03
|
Provenance
The following attestation bundles were made for pydantic_ai_trace-0.1.0-py3-none-any.whl:
Publisher:
release.yml on moritzwilksch/pydantic-ai-trace
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
pydantic_ai_trace-0.1.0-py3-none-any.whl -
Subject digest:
99aece16fb19a715c89ed1c070f6f3e8e39f1875df06c12da0909985fd054136 - Sigstore transparency entry: 2166937155
- Sigstore integration time:
-
Permalink:
moritzwilksch/pydantic-ai-trace@4e17ae81bda4a6f58e1c7b2dab0bb24a7931b424 -
Branch / Tag:
refs/tags/v0.1.0 - Owner: https://github.com/moritzwilksch
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
release.yml@4e17ae81bda4a6f58e1c7b2dab0bb24a7931b424 -
Trigger Event:
push
-
Statement type: