A hands-on guide to tracing AI agents with OpenTelemetry, span design, and SDK-level instrumentation for production systems.
Agent TracingLong read

The Instrumentation Checklist Enterprises Need Before an Agent Trace Can Be Audited Against Its Own Instructions

Seven telemetry records that let auditors check each agent step.

· 9 min read
Cover illustration for “The Instrumentation Checklist Enterprises Need Before an Agent Trace Can Be Audited Against Its Own Instructions”
Agent Tracing · November 11, 2026 · 9 min read · 2,089 words

Intent-aware auditing for AI agents compares each execution step with the instructions that governed it. Before that comparison is possible, enterprise telemetry must capture versioned instructions, linked step-level spans, validation results, decision records, and verified access records where authorization is involved. A healthy service and a complete conversation log do not establish instruction compliance.

Why standard enterprise instrumentation cannot support instruction-grounded trace auditing

A run completes with HTTP 200, throws no exception, and leaves the monitoring dashboard green while the agent violates policy. The service is healthy. The behavior is not. Conventional application performance monitoring was built for deterministic systems whose failures appear as errors, latency spikes, or downtime. An agent can instead plan, retrieve context, call tools, and move between models while producing well-formed but wrong results.

That difference changes what an audit must establish. Service availability cannot show whether the agent chose the right tool, passed the arguments the tool needed, or stuck to its original plan. Most enterprise instrumentation stops at the prompt-and-response boundary, leaving the decisions between those endpoints unrecorded. Instruction-grounded auditing requires those intermediate steps and the instructions that were supposed to constrain them.

The failure modes that instruction-grounded auditing must catch, and why each one requires its own telemetry layer

A tool field changed from incident_count to num_incidents, but the tool schema did not reflect the rename. The trace thus showed a call that looked valid under a contract that was out of date. Transport success concealed a mismatch in what the agent expected to receive. More generally, tool-call failures can return an empty array, a null value, or an error message inside a successful response without triggering exception monitoring.

Retrieval and context failures occur at another layer. A near-duplicate document may omit the fact required by the instructions, so the audit needs the actual retrieved documents. Planning and decomposition drift require a different record because individual turns can look reasonable while the overall run departs from its objective. The plan, chosen action, observation, and next decision expose that departure.

Context-window eviction removes governing instructions as messages accumulate. Memory poisoning and state corruption instead allow an early validation slip to contaminate later reasoning, even when intermediate outputs look plausible. These mechanisms need context utilization records and before-and-after state records, respectively. No single layer exposes every failure. When instrumentation covers only part of a run, the audit cannot tell apart causes that lead to similar symptoms at the end.

The telemetry foundation every other checklist item depends on — step-level spans in a common schema

The first prerequisite is a structural one. Every execution step must be a typed, inspectable span in a consistent schema, with timestamps and parent-child links that assemble one user request into an execution graph. Tool-call spans must record the tool name, arguments, raw output, duration, retry count, and error state. Reasoning spans must connect the plan, selected action, observation, and next decision rather than treating an entire run as one model response.

State transition spans must capture working memory before and after each step, including context edits and handoff payloads. Memory operation spans must record long-term store reads and writes, including queries, returned entries, relevance scores, and freshness. These records expose different parts of the causal chain. Together, they let an auditor follow how an input became a decision and how that decision changed the next step.

Multi-agent handoffs must keep the same parent-child structure. A flat set of spans cannot reliably show which agent acted under which instruction set. Missing links also prevent an auditor from following an upstream error into a downstream action. An audit that cannot reach a step cannot evaluate it.

Adopting OpenTelemetry GenAI semantic conventions as the portability prerequisite

OpenTelemetry GenAI semantic conventions define gen_ai.* span and metric attributes that make AI telemetry legible across backends and auditing tools. The conventions are still evolving, so adopting them is an instrumentation contract with an incomplete vocabulary. Their audit value lies in allowing records from different components to form one interpretable trace.

That contract must extend across execution boundaries. Every LLM call, tool call, retrieval, and guardrail check should appear as a standard OpenTelemetry span. When records from proprietary frameworks stay separate, they cannot show what happened across a multi-framework stack. Without a shared vocabulary, a change of auditing backend requires records to be translated before the audit can check whether instructions were followed.

How do you audit an agent against its original instructions? Capture them inside the trace

An audit that must leave the trace to find the governing instructions is a reconstruction. The system prompt, role definition, policy constraints, and per-run overrides must be versioned, immutable trace artifacts. Instructions change between deployments and sometimes between runs. Without the version used for the run, a later review cannot distinguish a prompt regression from model drift or a data-quality failure.

Each sub-agent needs an instruction binding of its own. If only the top-level system prompt is recorded, downstream decisions lack the benchmark they should be checked against. Tool schemas belong in that benchmark too, because a field rename can change the contract the agent reasons against. Finally, recording the intended instructions does not prove they remained in active context, so the trace must also retain per-step context state.

Tool output schema validation at the span boundary

A trace may keep the response that contains num_incidents while the agent still expects incident_count. Unless the span records the governing schema version and its validation result, the auditor cannot establish whether the response matched the contract. The call can look successful while its input to reasoning is defective.

Strict schema validation must run at every tool output boundary so the result is checked before it reaches the LLM. The span must keep both the raw output and the validation outcome. This separates receipt of a payload from acceptance of that payload under the recorded schema. Empty and null responses must be assessed against that contract.

The distinction is evidentiary as well as operational. Without validation, a later review may not distinguish an agent deviation from a decision made on bad tool input. With it, the audit can ask whether the tool returned what the agent's instructions said it should return. The recorded schema version supplies the reference for that judgment.

Intermediate state assertions after each major reasoning step

Validation must continue after data enters working memory. A failure originating at step 2 may become visible only at step 15, leaving the final output far from the point where corruption began. State transition spans link those points by recording what was in working memory before and after each major reasoning step. Context loss and summarization drift then become inspectable changes.

Lightweight deterministic assertions add a compliance judgment to those snapshots. They should check whether state variables remain within the boundaries defined by the instructions. A numeric range check alone is not enough when the governing requirement concerns what the state represents or permits. The assertion must test the relevant instruction.

This addresses the cascade described earlier directly. A trace of locally plausible outputs may hide an upstream error that later steps faithfully propagate. Recorded assertions show where state first failed to meet its constraints. They distinguish a history of what happened from evidence that each transition remained compliant.

Context window utilization tracking per step

Instruction capture establishes the intended benchmark, but not its continued presence during execution. As messages accumulate, system instructions and critical user constraints can be pushed out of active context. The model continues generating without an exception. Tool validation and state assertions do not, by themselves, record that loss.

Per-step context tracking is therefore a separate prerequisite. The trace must record token utilization and the proportion of the window occupied by system instructions versus conversation history. Combined with context state, those attributes make instruction presence auditable at a contested decision. A record of the original prompt alone cannot do that.

The operational complement is a context management policy. It should flag steps that exceed a defined utilization threshold without a structured summarization pass, and the threshold trigger must appear as a span event. This is more specific than asking whether the agent ran out of space. The audit must locate instruction loss and examine whether subsequent decisions diverged in ways consistent with it.

Loop detection and hard iteration limits as auditable span attributes

Repeated tool calls can look like progress when spans are reviewed one at a time. Across the run, however, they may show that the agent is no longer completing the task its instructions defined. Successful calls do not resolve that distinction. The trace needs a machine-readable signal of repetition rather than relying on a reviewer to recognize the pattern.

Loop detection should track the sequence of tool calls and record repeated patterns as span attributes. Retry counts belong in tool-call spans for the same reason. Hard limits on iterations and total execution time should be enforced at the instrumentation layer, with triggered limits recorded as span events. Those events make the intervention part of the evidence.

Termination must also be interpretable against the task. Completion, a hard limit, and an external interruption are different outcomes even if each ends the run. The audit needs to determine which occurred and whether it matched the instructions.

Decision trace logging — recording the reasoning behind each action, not just the action taken

An action record establishes what the agent chose. It does not establish how that choice followed from the task, the available evidence, and the governing constraints. Structured decision records must link the plan, action, observation, and next decision. These transitions expose plan drift and wrong-branch selection that a single LLM span cannot show.

This layer is harder to instrument than output logging. It requires the decision process to emit structured plans, decision branches, and plan-act-observe transitions rather than leaving the connection between actions implicit. The purpose is to make the stated basis for a choice inspectable against instructions.

For multi-agent runs, decision spans must keep parent-child links and the instruction set of the agent that made the decision. That structure helps distinguish a downstream consequence of an upstream output from an independent policy deviation. At the disputed step, the recorded rationale can then be compared with context telemetry. The audit can check whether the evidence shows that the agent misunderstood instructions, lacked them, or made a wrong inference despite stating its understanding accurately.

Identity-bound audit records for tool calls — why application-emitted telemetry is not sufficient

Access-control instructions require evidence outside the agent's own account. If the instructions permit access only to the authenticated user's records, an application-provided user identifier cannot establish who actually made the request or which access was authorized. A misconfigured or out-of-scope agent may describe its behavior accurately without recording its lack of permission. Engineering telemetry alone leaves that question unanswered.

Application spans and gateway audit records serve different purposes. The former explain the agent's actions and decisions. The latter establish who used which tool against which system, under which policy decision and data scope. A gateway between agents and the systems they reach must log Model Context Protocol (MCP) tool calls with identity resolved against the identity provider. The access-brokering layer supplies the independent record.

This requirement is especially important in regulated and multi-tenant environments. The trace must let the audit compare what the agent was allowed to access with what it did access, beyond the agent's own claim that it followed the instructions. Governance also includes storing traces where the regulator allows, masking or redacting sensitive fields, and recording guardrail decisions and overrides.

Connecting the trace to online evaluation — from auditable record to continuous instruction compliance

Once these records exist, live traces can be scored against the instructions captured within them. Offline tests are still not enough because production brings together user inputs, retrieval results, and tool outputs in ways the test set may not cover. Continuous evaluation examines those actual runs. Its quality depends on whether the trace exposes the relevant steps and their governing constraints.

The resulting failures should be grouped into recurring issues. Structured production failures can then become regression tests automatically, so fixes can be checked without someone rewriting every observed violation as an assertion. This closes the feedback loop between execution and evaluation.

For buyers assessing platforms, the decisive criterion is whether evaluation can bind each decision to its original instructions and the evidence available at that step. Prompt logging, error detection, and final-answer scoring are not substitutes for that capability. Alerts on instruction-compliance score drops should reach engineers where they already work.

Sources

  1. AgentTrace: A Structured Logging Framework for Agent System Observability
Filed underAgent Tracing

More in Agent Tracing