Tracing a run across models, tools, and policy checks

← Back to Blog & Articles

Distributed tracing makes an agent run navigable across planning, retrieval, policy, tools, storage, and human approval.

A trace is not a substitute for the audit log: tracing is optimized for causal investigation, while the event store is the system of record. The two share stable identifiers so an operator can move from a slow tool span to the policy decision and durable receipt that explain it.

For the traceparent and tracestate headers for trace propagation, see https://www.w3.org/TR/trace-context/.

The runtime creates a root span for each run and child spans for context assembly, model invocation, retrieval, policy evaluation, tool dispatch, reconciliation, and approval waits. Attributes use bounded identifiers, outcome classes, and versions rather than raw prompts, secrets, or full retrieved documents. Cross-process work carries correlation context, but that context never grants authority; authentication and policy remain independent controls.

Traces, metrics, and logs answer different operational questions. Traces expose a specific trajectory, metrics reveal population-level rates and latency, and structured logs retain selected diagnostic facts. OpenTelemetry describes these signals as related but distinct. The laboratory emits a deterministic trace tree and asserts that every external effect span links to its policy event and receipt, making orphaned actions visible during review.

Continue with the book

Explore the full treatment, worked examples, and exercises in Building Production-Grade AI Agents.


Companion article for Building Production-Grade AI Agents, published by Choral Software. Article text and original examples © 2026 Choral Software. All rights reserved.

Scroll to Top