Guides
AI agent tracing: connect execution steps to the action you need to verify
Understand what a trace records, how asynchronous actions complicate it, and what evidence an investigator needs before replaying a failure.
An agent trace records execution. To explain whether the agent achieved a business result, you also need the result’s meaning and the identity of the action it belongs to. A successful model call and a completed customer request are different observations.
Start with the execution structure
OpenTelemetry represents work as spans, with context connecting related execution across services. For an agent, useful recorded steps include retrieval, model generation, tool invocation and worker processing.
Retain inputs and outputs needed for investigation, the application version and relevant timestamps. Record truncation or redaction explicitly. A viewer cannot infer the original content of a missing tool result from the fact that the tool span exists.
Add business-action identity
Consider a synthetic order agent making two replacement requests in one conversation. A successful receipt for replacement B does not prove that replacement A succeeded. Record the action identifier, affected object, attempt identifier and authoritative result separately from the trace’s execution identifiers.
These are application evidence requirements, not a claim that one universal OpenTelemetry field automatically establishes business success. Document your schema and how identifiers propagate to workers and external callbacks.
Follow asynchronous work
A parent request may finish after dispatching a job but before that job completes. Capture the dispatch, worker acceptance, final result and receipt available to the parent. Preserve causal links where possible; wall-clock ordering alone is fragile across systems.
At investigation time, distinguish a pending operation from an explicit rejection and from missing telemetry. A trace labeled complete may describe a finished request while its business action remains unresolved.
Replay with controlled effects
Use a sandbox or a recorded tool-response fixture to reproduce the case. Re-running a production write can create another order or refund. Record which outputs are replayed and which are generated afresh, so the result is not mistaken for an independent real-world observation.
Trace IDs, operation IDs and attempt IDs solve different problems
A trace ID groups execution telemetry. An operation ID identifies the business action the user asked for. An attempt ID distinguishes retries of that action. Conflating them creates two common debugging errors: counting a retried operation twice, and using a successful receipt from the wrong action to justify a response.
run_id: run-12
trace_id: trace-a
operation_id: cancel-order-7
attempt_id: attempt-1
result: timeout
run_id: run-12
trace_id: trace-b
operation_id: cancel-order-7
attempt_id: status-readback-1
result: completed
observed_before_final_response: true
This synthetic example spans an initial request and a later status lookup. The timeout is an execution result; the completed readback is business evidence. The second record supports completion only if it is authoritative for that operation and available at the relevant assessment time. Neither a matching customer ID nor the last successful span is enough.
A debugging sequence for an apparently successful run
- Read the final response and identify its specific claim. “Requested” and “completed” are different statements.
- Locate the corresponding action and target object. Follow operation identity across workers and retries.
- Compare the original service result with the observation passed to the model. Look for adapters that collapse pending or rejected states into a generic success flag.
- Check time boundaries. Separate evidence available before the claim from later reconciliation.
- Save the smallest useful regression fixture with a healthy counterpart.
Replay is not the same as re-execution
Replaying stored observations can help inspect a prompt’s response to known evidence. Re-executing tools can create new side effects or encounter changed state. Label which procedure you use. For write operations, prefer a resettable sandbox and explicit fixtures; a second production cancellation request is not a harmless replay.
Download the runnable evidence lab to see ten structured cases covering wrong targets, missing receipts and late evidence. The script deliberately does not parse natural language or certify a service’s authenticity. Those boundaries make it useful for testing your evidence contract before adding a semantic evaluator.
Then change one part of the agent, compare the same cases, and inspect the evidence behind any score change. The business-outcome guide and recovery guide expand on the two most common joins.