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

APM Instruments Requests but Agents Fail Across Plans Not Across Requests

Agents can pass every request check and still follow the wrong plan.

· 9 min read
Cover illustration for “APM Instruments Requests but Agents Fail Across Plans Not Across Requests”
Agent Tracing · November 10, 2026 · 9 min read · 1,923 words

Traditional error monitoring fails for AI agents because it checks whether requests succeed, while agents can get every request right and still carry out the wrong plan. The cause may originate in retrieval, shape a later tool call, and be visible only in the final answer. Effective agent monitoring therefore needs plan-scoped traces and online evaluation of behavior against intent.

Why traditional error monitoring fails for AI agents

APM was built around an atomic request that succeeds or fails. An agent instead executes a plan across requests, retrieval steps, model invocations, and tool calls. A successful request establishes that an operation completed, but it does not establish that the operation advanced the user’s goal.

Traditional software often provides a signal at the point of failure. A null pointer throws an exception, a database timeout returns an error code, and an HTTP error propagates up the call stack. The signal identifies both failure and location. An agent, by contrast, can return HTTP 200, pass schema validation, and produce well-formed output that is semantically wrong.

This is why healthy logs can coexist with bad answers. Request-boundary monitoring can describe the operations without showing whether their relationship makes sense. The error and its visible effect may be separated in time and in the trace. Adding more request-level measurements does not, by itself, supply the missing connection between the agent’s goal, its context, and its actions.

How a plan-scoped failure propagates through a multi-step workflow

Consider a retrieval step that returns stale or malformed context. The reasoning step builds a plausible plan on that data, then constructs a tool call with the wrong arguments. The tool executes successfully, and the agent returns a confident answer. No request-level error needs to occur anywhere in this chain. The tool did what it was asked to do.

At each hop, the artifact can remain well-formed. The retrieval response contains valid JSON, the tool call matches its schema, and the model output is fluent. A trace of the tool request can therefore show a successful execution without exposing why its arguments were wrong. That diagnosis requires the context from which the agent constructed the call, connected to the later action.

Sherlocks’ analysis of 73 production agent environments from January–May 2026 found that retrieval failure was the upstream cause in 61% of multi-layer failures. Wrong tool selection was not the cause in those cases. The agent called the right tool with the wrong context. This distinction changes where an engineer must look, because inspecting tool selection alone would leave the originating failure unexplained.

A crash at step 3 provides a stack trace. A silent failure at step 3 can instead produce a wrong result at step 10 without indicating where the plan diverged. Errors written to memory, vector stores, or knowledge bases continue to influence future reasoning even after the original source is corrected.

The six layers where agent plans actually break

Diagram: Where Agent Plans Actually Break: The Six-Layer Failure Stack. Visualizes: Visualize a ranked vertical stack of the six layers where agent plans fail, as identified by Sherlocks AI's Agent Failure Stack: (1) Tool Calls, (2) Retrieval, (3)…

Sherlocks AI’s Agent Failure Stack organizes production failures into six layers, namely tool calls, retrieval, memory, planning, permissions, and observability. These layers distinguish the origin of a problem from its downstream appearance. Tool calls and retrieval form the first two layers. Engineers need to look at a tool call with wrong arguments, but the retrieval context may explain where those arguments came from.

The third layer is memory and long-chain drift. It has the longest mean time to detect among the first five layers because an agent can lose its original goal while producing locally plausible outputs. Isolated steps can still look entirely reasonable. The failure becomes visible only when the full sequence is traced from its starting intent to its eventual result.

The fourth layer covers planning and decomposition. An agent may solve the right subproblem in the wrong order, or solve the wrong subproblem correctly. Both can happen without a tool failure or schema error. The fifth layer is permission boundaries, which include stale OAuth tokens or API keys that expire mid-task. An agent may continue producing output from tool calls that silently returned authentication errors, without retrying them.

The sixth layer is the failure of observability itself. These incidents have no monitoring-based detection mechanism and therefore no monitoring-derived mean time to detect. These incidents come to light through a support ticket, a billing discrepancy, or a customer complaint. Sherlocks’ data shows that such incidents take dramatically longer to resolve than incidents with full decision-trace logging, because the signal that starts the investigation lacks the execution context needed to explain it.

Why teams discover plan-level failures through complaints rather than alerts

The fintech fraud-detection agent case shows how apparently ordinary requests can conceal an abnormal plan. Cost grew dramatically quarter-on-quarter as agentic retry loops multiplied token consumption. No single request was anomalous, so no alert fired. The total cost grew past reasonable thresholds but stayed below the configured alerts because those alerts did not track the repeated work across the whole task.

The agent had authority to act without instrumentation comparing its intended behavior with what it actually did. That is the common structure behind the discovery gap. Permission to execute is not evidence of correct execution. Where this comparison is absent, downstream business signals become the detection mechanism, after the same behavior may already have repeated across many executions.

A dashboard can show that an agent is running while saying nothing about whether it is producing correct results. Hours of silent failure can pass before anyone looks. Detecting the fintech pattern earlier would have required token and step budgets within the task, while diagnosing a wrong answer would have required the context and actions that produced it.

What plan-scoped instrumentation actually requires

Plan-scoped instrumentation must connect each step to the execution it belongs to. The emerging model uses OpenTelemetry-based nested spans for each agent step to look beyond what a request alone can show. Span relationships are part of the diagnostic evidence. They must let engineers follow how retrieved context informed a model call and how that call led to a tool execution.

An execute_tool span of kind INTERNAL captures the tool name. Arguments and results are opt-in attributes. Recording arguments before execution exposes the call the agent constructed. A chat/inference span of kind CLIENT covers the model call, with model and token usage as recommended rather than required attributes, while input and output messages are also opt-in.

OpenTelemetry’s MCP semantic conventions address duplication across instrumentation layers. When MCP instrumentation can reliably detect that outer GenAI instrumentation already traces a tool execution, it should enrich the existing span. That behavior may require a configuration option. Without reliable detection, the conventions do not establish that enrichment will replace a separate span.

Within this span model, four instrumentation layers provide the evidence needed to investigate a plan. The first is the full context window at every step, so a retrieval investigation shows what the agent actually received. The second is tool arguments captured before execution. Post-execution logging alone loses the pre-action signal needed to distinguish a wrongly constructed call from a problem in execution.

The third layer compares reasoning with action where the framework exposes a plan or reasoning trace before an action. That comparison can show context corruption before the final answer does. The fourth captures token and step budgets at step level. A retry loop that doubles consumption at one step can disappear inside session-level aggregates, even though that step provides the clearest location for investigation.

Framework support provides practical entry points. OpenAI Agents SDK traces by default, wrapping runs in traces with nested spans for agent invocations, LLM generations, tool calls, handoffs, and guardrails. The Traces dashboard exposes those records. Tracing can be disabled with OPENAI_AGENTS_DISABLE_TRACING=1, while processors can fan traces out to other backends.

The late-2026 framework paths also have settings that must be set explicitly. Vercel AI SDK v5/v6 enables automatic tool-call tracing through the experimental_telemetry option with isEnabled set to true on each generate or stream call. The wrapAISDK(ai) helper is vendor-specific, and v7 uses a separate telemetry integration. Google Cloud Agent Engine supports built-in LangGraph tracing through enable_tracing=True, exporting to Cloud Trace, while custom agents require manual OpenTelemetry instrumentation.

Alerting on the score, not the status code

Catching a plan-level failure also requires an evaluation layer above infrastructure monitoring that scores live outputs against a machine-checkable definition of intent. The alert then follows the score. This is how monitoring distinguishes a fluent wrong answer from a fluent correct answer when their request-level signals look the same.

The evaluation criteria must correspond to the failure stack. Tool-call evidence supports checks on actions, while credential health checks address permission failures. Retrieval, memory drift, and planning need signals that link context and behavior to the result the task was meant to produce. Those layers may produce no infrastructure error at all. An evaluator must therefore assess more than whether the last model response was well-formed.

A quality-score drop beyond a meaningful threshold in a rolling window can signal regression or data drift. Token-count monitors, together with step-count-per-task alerts, can flag tasks that use more than a multiple of their expected token budget. That would have exposed the fintech retry-loop pattern before costs compounded. P0 paging conditions include a task that runs far beyond its P95 completion time, restarts that keep happening within a short window, and a tool credential health check that fails.

Noise control is part of this design. Sampling production traces, using an evaluator from a different model family, and alerting on consecutive failures in the same category can separate recurring patterns from individual score drops. Behavioral assertions also provide a more stable basis than exact output text. Which tools an agent called, which files it touched, and whether it ran tests are more durable checks than wording that can vary across correct responses.

When production failures are found, they should become new regression evals automatically. These evals should keep the condition that caused the failure so engineers do not have to hand-write every assertion. This connects live detection to verification after a fix ships. This also lets future alerts draw on specific behavior as well as a broad quality score.

Closing the loop from detection to fix without leaving the IDE

Detection becomes useful remediation when the monitoring layer delivers context to the place where engineers act. In 2026, that increasingly includes a coding agent in the IDE. MCP provides a connection between those workflows. The QueryLens MCP server, merged in October 2026, exposes list_projects, list_issues, get_issue, list_regressions, and set_issue_status over stateless Streamable HTTP, allowing a coding agent to query identified regressions directly.

A single trace presents a debugging task, while a grouped issue can provide a recurring pattern, a proposed root cause, and code context. The latter supports remediation inside the IDE. Grouping does not replace the trace, but makes its evidence usable without requiring engineers to reconstruct the same pattern from individual executions.

A one-line spec file change caused an agent to skip tests on every PR, with nobody noticing because nothing broke. The fix was a regression suite for the prompts themselves, using frozen repo snapshots, canned tasks, deterministic graders, and an LLM judge gated in CI. The failure was behavioral, so the safeguard had to test behavior.

The complete loop begins when an online eval detects a plan-level failure. A grouped issue identifies the pattern, and the trace supplies the context needed to diagnose it. A coding agent receives that context through MCP to support the fix. The production failure then becomes a regression eval that gates future deployments, so verification tests whether the plan’s behavior was corrected.

Filed underAgent Tracing

More in Agent Tracing