Skip to main content

tracewright

CI PyPI Python OpenSSF Scorecard

Capture Pydantic AI OpenTelemetry model spans as local, versionable pydantic-evals datasets.

Tracewright removes the manual step between observing a useful agent run and turning it into an eval case. It preserves the prompt, expected output, model, token usage, timing, and trace identity. Pydantic Evals continues to own dataset storage, evaluators, execution, and reports.

Pydantic AI run -> OpenTelemetry model span -> Pydantic Evals Case

Quick start

The example uses Pydantic AI's TestModel, so it needs no provider key or hosted observability service.

pip install "tracewright[pydantic-ai,pydantic-evals]"
from opentelemetry.sdk.trace import TracerProvider
from opentelemetry.sdk.trace.export import SimpleSpanProcessor
from pydantic_ai import Agent, InstrumentationSettings
from pydantic_ai.capabilities import Instrumentation
from pydantic_ai.models.test import TestModel

from tracewright import PydanticAITraceExporter, to_pydantic_evals_dataset

exporter = PydanticAITraceExporter()
provider = TracerProvider()
provider.add_span_processor(SimpleSpanProcessor(exporter))

agent = Agent(
    TestModel(),
    instructions="Answer concisely.",
    capabilities=[Instrumentation(settings=InstrumentationSettings(tracer_provider=provider))],
)
agent.run_sync("What is 2+2?")

dataset = to_pydantic_evals_dataset(exporter.rows, name="agent-regression")
dataset.to_file("agent-regression.yaml")
print(exporter.stats)

The resulting file is a normal Pydantic Evals dataset. Review it, commit it with the code it protects, and evaluate future agent versions against it.

The complete runnable example is examples/pydantic_ai_to_evals.py.

Contract

PydanticAITraceExporter is a standard OpenTelemetry SpanExporter. Attach it to the tracer provider already used by Pydantic AI. Its rows property returns an immutable snapshot suitable for to_pydantic_evals_dataset.

Each replayable model span becomes one pydantic_evals.Case:

Case field Source
inputs Last user message
expected_output Assistant text output
metadata The complete TraceRow, including system instructions, model, tokens, timing, and trace IDs

Non-model spans are ignored. Model spans with missing, redacted, or malformed content are counted in exporter.stats and are never silently promoted into eval cases.

Content capture is a privacy decision. Pydantic AI instrumentation with include_content=False still produces useful telemetry, but it cannot produce replayable prompt and output pairs.

Boundaries

Tracewright deliberately does not:

  • replace Pydantic Evals evaluators, execution, or reports;
  • replace Logfire trace storage or hosted datasets;
  • query the Logfire API or decode OTLP payloads;
  • reconstruct tool calls, full multi-turn state, or SpanTree objects.

parse_pydantic_ai_jsonl remains available for files containing exactly one serialized span object per line. It is not a generic Logfire export or OTLP reader. Enriched Tracewright/f3dx JSONL and the original replay CLI remain as compatibility surfaces.

tracewright replay traces.jsonl \
  --candidate myapp.replay:my_candidate \
  --candidate-model candidate-v2 \
  --report html=report.html \
  --budget "pass_rate=>=1.0,latency_p95=+10%"

New integrations should use PydanticAITraceExporter and Pydantic Evals.

Development

python -m pip install -e ".[dev]"
ruff check src tests examples
mypy src
pytest -q
python examples/pydantic_ai_to_evals.py

CI runs on Linux, macOS, and Windows with Python 3.10 and 3.12. It also replays Tracewright's serialized TraceRow contract across supported Pydantic versions using Pydantic Canary.

License

MIT

Release files for tracewright 0.1.1

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for tracewright 0.1.1
File Size Uploaded
tracewright-0.1.1.tar.gz 27.4 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for tracewright 0.1.1
File Interpreter ABI Platform
tracewright-0.1.1-py3-none-any.whl Python 3 none any Details

Total release size: 53.3 kB

Release files / tracewright-0.1.1.tar.gz

Download URL tracewright-0.1.1.tar.gz
Size 27.4 kB
Tags Source
SHA-256 checksum
How to use checksums
e99270394a39d59cae78a6cf68ab75514eb6cab91b55b0f5d3f2072dfd074a19
BLAKE2b-256 checksum
How to use checksums
3431670de5a104e8cc0e5400a0466e7e21feffeac0d256424ec59de393e8cc1c
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.14

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Aug 22, 2026.

Transparency log

Release files / tracewright-0.1.1-py3-none-any.whl

Download URL tracewright-0.1.1-py3-none-any.whl
Size 25.8 kB
Tags Python 3
SHA-256 checksum
How to use checksums
92a1ea2ca555b1d50c5e6a35721b00fb63e5906e6ce867afc6dffaf9d4f639d9
BLAKE2b-256 checksum
How to use checksums
650f2b51954782d66d3456bc1e8f572eb53e546f04c0894c1b594995d9103802
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.14

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Aug 22, 2026.

Transparency log

Release history Release notifications | RSS feed

This release

0.1.1 This release

2 release files

0.0.8

2 release files

0.0.7

2 release files

0.0.6

2 release files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page