Agent Trace SDK (agtrace)
Agent-aware tracing. Spans, events, and tool calls for LLM-driven workflows.
Why
Generic OpenTelemetry models web servers and database calls. AI agents need a different shape: prompts, tool calls, retries, fallbacks. agtrace borrows OTel's span tree but specializes the kind taxonomy so traces remain useful for debugging agents.
agtrace is the data primitive that apr-app and (eventually) sts-app will emit telemetry into — one trace per PR review, one span per LLM call, one span per tool invocation, all stitched together.
Status
v0.0.1 alpha. In-process tracer + JSONL exporter + CLI dump. OTLP / Jaeger / hosted-collector exporters land in v0.1+.
What v0.0.1 ships
agtrace.tracer.Tracerwith a context-manager API.- Span kinds tuned for AI workloads:
agent·prompt·tool_call·retry·fallback·unknown. - Automatic trace tree (parent / child via
ContextVar— works under asyncio + threads). - Exception handling: an exception inside a span sets
status="error"and records the exception type as an attribute. The exception still propagates. - Configurable exporter: default JSONL appender;
in_memory_tracer()for tests; bring-your-own callable for OTLP / Sentry / Datadog. - CLI:
agtrace dump --from-file traces.jsonlpretty-prints a trace tree.
Usage
from agtrace import default_tracer
tracer = default_tracer() # writes to .agtrace/traces.jsonl
with tracer.span("agent.run", kind="agent", attributes={"agent": "pr-reviewer"}):
with tracer.span("llm.call", kind="prompt") as s:
s.set_attribute("model", "claude-sonnet-4-6")
s.set_attribute("max_tokens", 1024)
# ... call your LLM here ...
s.add_event("rate-limited", attributes={"retry_after": "1.5"})
with tracer.span("tool.call", kind="tool_call") as s:
s.set_attribute("tool", "read_file")
# ... run the tool ...
agtrace version
agtrace dump --from-file .agtrace/traces.jsonl
# Renders a Rich tree:
# agent.run (agent) (124ms)
# agent=pr-reviewer
# llm.call (prompt) (98ms)
# model=claude-sonnet-4-6
# tool.call (tool_call) (12ms)
# tool=read_file
Roadmap
- v0.1 —
OtlpExporter(OTLP/HTTP) so traces ship into Honeycomb / Grafana / Datadog. - v0.1 — context propagation across HTTP boundaries (
agtrace.propagation). - v0.2 — sampling + rate-limiting for production volume.
- v0.3 — integration with
tokencostso eachpromptspan carries the cost in its attributes natively.
Apache-2.0 license. See CHANGELOG.
Metadata
Release files for devtrust-agtrace 0.0.2
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | |
|---|---|---|---|
| devtrust_agtrace-0.0.2.tar.gz | 11.9 kB | Details |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| devtrust_agtrace-0.0.2-py3-none-any.whl | Python 3 | none | any | Details |
Total release size: 21.8 kB
Release files / devtrust_agtrace-0.0.2.tar.gz
| Download URL | devtrust_agtrace-0.0.2.tar.gz |
|---|---|
| Size | 11.9 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
6ac931e228e4fb84cafad6b5b63b2202137c3d0982dfc1fe92cc4313c9ac8fd3
|
|
BLAKE2b-256 checksum How to use checksums |
181c86e09d9a43f7518ff3ad2df122dd27a5d43a6a97cf98b38a4582768ba0c1
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/6.1.0 CPython/3.13.12
|
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 May 9, 2026.
Transparency logRelease files / devtrust_agtrace-0.0.2-py3-none-any.whl
| Download URL | devtrust_agtrace-0.0.2-py3-none-any.whl |
|---|---|
| Size | 9.9 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
6ee200e3a43ac0919c14f13742cbffd10ffa67e3a27691af204f0427d16e548d
|
|
BLAKE2b-256 checksum How to use checksums |
e9f47918ff5816c279970699c76461381b916f8efcf8b145ad058f10ea1da0fc
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/6.1.0 CPython/3.13.12
|
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 May 9, 2026.
Transparency log