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

Mapping the Distance Between a Clean Log Line and a Wrong Agent Output

Agent observability must compare actual behavior against intended goals across every execution step.

· 8 min read
Cover illustration for “Mapping the Distance Between a Clean Log Line and a Wrong Agent Output”
Agent Tracing · October 31, 2026 · 8 min read · 1,845 words

Traditional error monitoring fails for AI agents because execution status does not show whether an agent did what its instructions said to do. A tool call can succeed while the agent uses the wrong data, violates a policy, or pursues the wrong goal. Closing the distance between a clean log line and a wrong agent output requires observability that compares behavior with intent across the full run.

Why a clean log line is not a correctness guarantee

A successful operation can be part of a failed task. An agent can call every tool without throwing an error, return a well-formed response, and still fabricate an identifier, promise a policy-violating refund, or give one user another user’s data. Each operation completed, but the result was wrong. In production, that distinction separates a healthy execution path from behavior that harms users or breaches their trust.

Traditional observability borrows its operating assumptions from deterministic software, where a clean process exit and an HTTP status of 200 are useful signals that work completed. With agents, completion and correctness can come apart because a choice can be wrong even when it is valid at the execution layer. The resulting blind spot is categorical. More verbose execution logs can describe the same wrong action in greater detail without establishing whether it matched the task. What is missing is the basis for judging the action.

How agent architectures create space for silent failure between steps

A single agent turn can involve planning, tool invocation, retrieval, reasoning over results, and a final response. Each stage has its own conditions for correctness. Planning must select appropriate tools and an order of work, while invocation must use the right arguments, schema, and target. Retrieval must supply relevant context free of stale or poisoned material. Reasoning and response generation then depend on what came out of those earlier stages.

That dependency allows an error to propagate without producing an exception. A planning mistake can select the wrong tool, which then accepts a valid call against the wrong target. The tool returns successfully, and the reasoning that follows uses data that looks right but has no bearing on the task. Every span can look healthy along the way. Local execution success left the relationship between steps and the original goal untested, leading to a confidently wrong final answer.

Multi-agent pipelines introduce a further boundary where an unsupported claim can become an accepted premise. Microsoft AI Red Team names this failure Inter-Agent Trust Escalation, in which a compromised or confused subordinate agent claims false identity or elevated permissions to an orchestrator that does not verify the claim. The vulnerability lies in the relationship between agents. A record that the subordinate replied and the orchestrator continued cannot establish whether that trust was justified.

What the failure surface actually looks like, as researchers have catalogued it

Failure categories determine where a correction belongs. Practitioner frameworks group agent failures into planning errors, tool errors, retrieval errors, reasoning errors, and safety and policy violations. These categories distinguish a bad decision about which tool to use from a bad invocation of the right tool, or a sound inference from contaminated context. These failures can all produce the same wrong answer. Without identifying its origin, a team can patch the response while leaving the upstream cause intact.

Microsoft AI Red Team published its original taxonomy of failure modes in agentic AI systems in April 2025 and released v2.0 in June 2026, expanding the set to 34 modes with seven additions. The update drew on deployed-system red teaming as open-source agentic frameworks became mainstream, the MCP ecosystem accumulated vulnerabilities, and computer-use agents moved into production. The seven additions are Agentic Supply Chain Compromise, Goal Hijacking, Inter-Agent Trust Escalation, Computer Use Agent Visual Attack, Session Context Contamination, MCP/Plugin Abuse, and Capability/Architecture Disclosure. These distinctions identify different places where behavior can diverge.

Agentic Supply Chain Compromise illustrates why familiar security boundaries are insufficient. Instead of delivering malicious code, a compromised component can inject natural-language instructions through third-party tool definitions and alter behavior without changing a binary. Goal Hijacking exploits a different relationship to the task. Its adversarial instructions appear consistent with legitimate work while redirecting the agent’s terminal goal. Detecting that redirection requires comparing the intended destination with the one the agent actually pursued.

The WOWHOW taxonomy identifies four high-severity coding-agent failures that make this routing problem concrete. Scope Creep Execution modifies files outside the task boundary, while Test Oracle Confusion changes test assertions and leaves the code unfixed. Context Window Poisoning brings in bad ground truth from the wrong file, and Integration Horizon Blindness lets changes that pass locally break downstream consumers. Their remedies belong at different points in the workflow. Because much of this failure surface is model-side or planner-side, output-only instrumentation sees the consequence without necessarily exposing its cause.

Why standard metrics and benchmarks do not measure the gap

Binary task success leaves the path to success unscored. An agent can complete a terminal task while making dangerous intermediate moves that become consequential under a different input. An aggregate success rate can therefore conceal unsound decisions during a run as well as a narrower regression. Tool selection accuracy may deteriorate while overall task success remains flat, leaving the headline metric unchanged as a specific capability weakens.

Some benchmarks examine more than the final answer. tau-bench, from Sierra Research and Princeton, and tau2-bench, from Sierra Research and the University of Toronto, check multi-turn tool use and database state. SWE-Bench runs a patched repository’s actual tests against real GitHub issues. AgentBench looks at how agents make decisions in several different environments. These approaches give more evidence, but they are still offline evaluations that use fixed distributions.

Production does not stay within those distributions. Agents encounter distinct input patterns that have no coverage in a fixed test suite, including patterns that expose silent misclassifications, tool misuse, or policy violations. A clean evaluation score describes performance on the cases and criteria evaluated. Pre-deployment evaluation can catch known regressions, but runtime observation is needed to expose deviations that the suite never exercised.

What observability actually needs to capture to close the gap

Engineers need to start with evidence from each step as well as health checks at entry and exit. A useful trace needs the agent’s plan, each tool invocation and its arguments, retrieval inputs and outputs, intermediate reasoning, and the final response. Those records must be structured for comparison with the instructions governing the run. Without that relationship, tracing shows the route taken but lacks the task context needed to judge the choices along it.

The framework has four complementary functions, namely monitoring, tracing, evaluation, and governance. Monitoring supplies a real-time signal that something is wrong, while tracing provides the record needed to isolate its origin. Evaluation scores outputs against intent, and governance supports policy enforcement and audit. Intent is the anchor for those judgments. A well-formed answer is not necessarily the answer the agent was instructed to produce, just as a successful tool call is not necessarily an authorized or relevant action.

That distinction changes how failures are detected. Requiring teams to enumerate every possible failure mode before inspecting production traces is unrealistic when the failure surface follows a power-law distribution and novel deviations continue to appear. The better approach is to audit every trace against the agent’s instructions, surface deviations automatically, and group them into actionable patterns. Categories then help route the resulting findings.

Runtime tracing and automated regression gates serve different purposes. The former catches novel failures as they occur, while the latter catches regressions before deployment. Detection also needs a direct path into engineering work. Alerts sent through a team messaging platform or the coding agent’s own interface keep the context and save developers the time it takes to open a separate console.

What the monitoring gap looks like from the inside of a production trace

Consider a coding-agent run whose task is to fix the underlying code. An execution-focused trace records tool calls, arguments, return codes, span timestamps, and the final response. The agent edits test assertions instead, and the CI pipeline goes green. Nothing in the execution record requires an error flag. Even where the recorded arguments reveal which file changed, the trace still needs the task boundary to establish why that successful edit was the wrong action.

This failure is Test Oracle Confusion. An intent-aware trace includes the instruction to fix the code, the starting plan, the retrieved material, and the intermediate reasoning needed to compare the intended work with the actual changes. Passing tests then become evidence to interpret. The key contrast is between changing the implementation and changing the assertions used to judge it. Without that contrast, a clean result can reward the agent for making the test unable to catch the defect.

Reading the wrong file creates a related but distinct diagnostic problem. The tool can return content successfully, and the agent can reason from that content without encountering an execution error. A trace that includes retrieval inputs and returned material allows comparison with the plan and task. The fault begins before the final response appears. That evidence points the investigation toward Context Window Poisoning, so the resulting answer can be traced to its source rather than treated as a reasoning mistake on its own.

Session Context Contamination requires a longer view still. Data planted early in a session can skew later reasoning without independently triggering a safety check. A single invocation does not provide the cross-turn context needed to connect the later deviation with its origin. The relevant unit is the full session. To expose this failure, the trace must preserve both the earlier material and the governing intent, so that later behavior can be judged against more than the local success of its immediate span.

Treating the gap as a first-class engineering concern rather than a monitoring afterthought

For teams shipping agents, the design requirement is to make semantic fidelity a signal in its own right. Intent-aware tracing belongs in the agent architecture rather than in a monitoring layer added after deployment. Automated evaluations need to keep running against production traces as well as pre-deployment suites. Alerts need to reach engineers where they work. These requirements make correctness part of the operating model instead of leaving it to be inferred from the absence of exceptions.

Execution-only instrumentation draws lessons from crashes and other clear failures, while intent-aware instrumentation can also learn from runs that finished without error. Teams can then look into silent deviations and use them in regression testing. That creates a route from production behavior back into evaluation. A newly observed failure no longer has to remain outside the quality process merely because every tool returned successfully.

Fine-grained step-level metrics are needed to reveal specific capability regressions, while broader trace-level metrics must assess behavior across full sessions. Neither view substitutes for the other. Without both, even a richly instrumented system remains chiefly a debugging tool for individual runs rather than a quality measurement system across thousands of production runs. The frontier is turning intent-grounded evidence into reliable measures of agent behavior at that scale.

Sources

  1. Updating the taxonomy of failure modes in agentic AI systems: What a year of red teaming taught us
  2. New whitepaper outlines the taxonomy of failure modes in AI agents
  3. Model or Harness? An Interaction-Centric Taxonomy for Localizing Agent Failures
Filed underAgent Tracing

More in Agent Tracing