Four Harness Layers Every Stack Trace Ignores and How to Get Answers From Each
Diagnose agent failures at the prompt, tool, workflow, or memory layer.

AI agent failure attribution by harness layer means finding the earliest unrecovered failure in the prompt, tool, workflow, or memory layer, rather than blaming the model call where the error surfaced. Each layer needs its own evidence, from the content of versioned prompts to memory operations across sessions. Production traces become diagnostic only when that evidence connects a decision to its consequences, and replay tests whether the proposed fix repairs them.
Why stack traces are structurally blind to where agent failures originate
An agent returns a wrong answer after a long sequence of apparently reasonable actions. Its tool calls completed, its retries looked defensible, and the final response arrived without an exception. Nothing in the stack trace identifies the cause. The developer can see where execution ended, but not where the agent lost the information or direction needed to succeed.
Standard application-performance monitors show execution errors at the model boundary. The harness supplies tools, memory, guardrails, and workflow control, yet a flat trace can collapse that execution layer into a single “LLM call.” AgentDebugX identifies the resulting separation between the step where an error surfaces and the step that caused it. Replaying the execution history alone rarely closes that gap.
The evidence may sit several actions upstream. Scale AI’s Continual Search paper describes attribution as a search problem because relevant information is sparse and distributed across distant actions. Automated diagnoses are less reliable on longer traces when they settle on an explanation that seems right before checking the evidence that could decide the case. That shortcut can turn context truncation or a runaway loop into an apparent model error, prompting an unnecessary intervention.
The four harness layers a trace collapses into one call
The four layers define distinct failure domains. Prompts and context assembly determine the instructions and information presented to the model, while tools and schema contracts govern its interactions with external capabilities. Workflow and execution loops control retries, handoffs, and progress through a task. Memory and state keep information within a session and from one session to the next. Silent quality changes, contract drift, non-converging trajectories, and lost context therefore require different diagnostic methods, even when each produces the same wrong answer.
Prompt and context assembly failures: detecting silent degradation before it spreads
The Madani workspace case exposes a prompt failure in a lead-generation workflow running roughly 180 tasks per day. Its remediation was a “structured ambiguity probe” that asked the agent to enumerate uncertainties about prospect intent before sequencing decisions. The intervention changed how the agent framed its next action. It addressed the instructions rather than the model weights, making the prompt layer the relevant diagnostic target.
These failures need not produce an execution error. A small wording change can redirect tool selection or weaken adherence to guardrails while every subsequent call remains valid. MAST places ambiguous prompts and role mis-specification in Specification Issues, its largest failure category, while treating inadequate verification separately under Task Verification. That distinction prevents a missing instruction from being confused with a missing check on the result.
The practical method is to record prompt version ID with model ID, then compare versions through A/B quality measurement. A quality-score drop in a rolling window supplies the signal. The trace must keep decision content as well as the version. TelemetrySuffBench found that origin-step accuracy fell to zero for every model it tested when decision content was removed. Versioning the input, comparing quality, and correlating the change with traces also applies to tools, but tool contracts introduce an additional risk that quality monitoring alone cannot isolate.
Tool and schema contract failures: catching drift before the model notices
A tool contract can break without an exception. The agent’s expectation of accepted inputs is encoded at call time, while model updates, prompt edits, and API changes can alter how that contract is used. Specific names such as calculate_monthly_tax_v2() reduce the selection ambiguity of names such as process_data(). They do not prevent drift at the field level, where the expected schema and the actual interface can diverge.
The Madani voice-channel case shows why successful execution is an insufficient test. TTS-side encoding mismatches produced silence segments that the agent did not detect. Instrumenting tool result status and retry count made the failure traceable. The relevant evidence therefore lay in the tool interaction.
To catch that drift, the recommended method pairs CI-side schema snapshot testing with replay of a golden trace set against current production on a set schedule. Snapshot testing records schemas, diffs them on each run, and fails on breaking changes. Replay tests their effect on established behavior. Production traces also need tool name, sanitized arguments, result status, and retry count, with provenance linking each decision to its invocation. Without those connections, repeated calls can look like a workflow defect when the underlying cause is a broken tool contract.
Workflow and execution loop failures: distinguishing a stuck agent from a confused one
A failed tool call followed by a retry is not, by itself, a workflow failure. The distinction appears across the trajectory. A loop that persists despite successful tool calls points toward a failure to converge, whereas retries following tool failures require investigation of the tool layer. Checking one step at a time cannot reliably tell them apart because each action may seem reasonable on its own.
A single request can span dozens of model calls, tool invocations, sub-agent handoffs, and retries. MAST identifies reasoning-action mismatch as a specific failure type in which the agent states one intended action and calls a tool for another. Diagnosis requires comparing the stated plan with the actual sequence. Similarly, the Madani agent’s repeated qualifying question after a prospect had answered was a loop symptom caused by working-context corruption.
Trajectory-level instrumentation should capture handoff source and destination, sub-agent call depth, and retry count per tool. An alert on tool call count above the P99 baseline for that task type provides a practical trigger for investigation. The investigation must still follow the evidence upstream. Continual Search uses iterative, multi-turn investigation to avoid stopping at the first plausible explanation. ReplayRCA likewise found that causal repair performance fell sharply when only the last step could be changed, which shows why the terminal symptom is a poor place to start a repair.
Memory and state failures: the layer that degrades across sessions, not within them
Memory diagnosis adds a time dimension that one execution trace cannot supply. Working memory holds the current conversation and short-term task state, while episodic memory contains summaries of earlier sessions. Semantic memory includes embeddings of relevant documents or past decisions, and procedural memory preserves learned tools, patterns, and workflows. Their failure signatures differ. Context can become corrupted, summaries can drift, retrieval can become stale, and learned workflows can fall out of use.
Working-context corruption can occur within a run, as the repeated qualifying question in the Madani case demonstrates. Longer-term degradation becomes visible only across sessions as context compresses, sessions reset, and drift accumulates. The trace therefore needs retrieved document IDs, memory operations including read, write, and evict, and session boundary markers. These fields connect the onset of failure to the information available at that time. They also distinguish a workflow-shaped symptom from a memory-layer cause.
Production traces that fail an online scorer become eval cases, adding failures from real user behavior to the suite. AgentDebugX’s Error Hub formalizes a related diagnostic memory through scrubbed failure-diagnosis-repair bundles that teams can reuse. Without that record, the same failure can receive a new explanation each time. “The model forgot the rule” may actually describe a harness that no longer supplied it.
Why teams reach for retraining when harness iteration is usually the right lever
Retraining has a role when the policy itself needs to improve. Compact, low-latency models trained on a fixed harness can overfit to that configuration and fail to evolve with harness updates. Offline teacher trajectories also lack a learning signal from the model’s own failed attempts and recoveries. The TaoLive team addressed that limitation with a production-informed simulator for on-policy RL.
That does not make retraining the default remedy. If a prompt is ambiguous or memory management discards required context, changing model weights targets the wrong component. Frequent harness changes also make retraining a recurring cost. Independently versioned harness modules allow new skills and tools to be deployed without repeating that cycle.
The “Harness Agent” design separates a slowly updated policy model from rapidly evolving harness state. This separation permits business behavior to change without requiring every update to become a model-training project. Attribution determines which side needs intervention. A team needs evidence of which layer caused the failure to choose between prompt repair, contract repair, state-management changes, and learning from failed trajectories.
What trace schema will pinpoint which layer caused a production failure?

TelemetrySuffBench (2026) makes the instrumentation gap concrete. Its OpenTelemetry-compatible views and views that work with another telemetry specification kept near-perfect failure detection F1, but origin-step accuracy fell to near zero with those stripped-down views. With full telemetry, the model that performed best reached 97.2% origin-step Top-1 accuracy. Detection and localization are separate capabilities. A format that reports failure reliably does not necessarily preserve enough evidence to identify its origin.
A diagnosable schema combines content, identity, and execution relationships. Prompt records need model ID, prompt version ID, input and output token counts, and finish reason, while tool records need name, sanitized arguments, result status, and retry count. Workflow records need handoff endpoints, sub-agent call depth, and call count relative to the task-specific P99 baseline. Memory records need retrieved document IDs, read/write/evict operations, and session boundaries. These fields supply the evidence for the distinct comparisons each layer requires.
Content and provenance cannot be treated as optional extras. The benchmark also found that origin-step accuracy fell sharply when provenance was removed, with the size of the loss depending on the model. Version metadata can locate a change in time, but decision content explains what changed in the agent’s reasoning or instructions. Provenance then connects that decision to the tool or resource it used.
Teams should choose a platform based on what they need it to diagnose. Braintrust, Humanloop, and Arize Phoenix support quality metrics, while LangSmith, Langfuse, and OpenTelemetry custom spans support analysis of tool call patterns. Arize and WhyLabs support drift monitoring. Moda ingests production traces, attributes failures to prompt, tool, workflow, or memory, and generates reviewable improvements validated against historical traces before recommending what to ship.
Replay validation as the pre-ship gate that connects diagnosis to confident deployment
A layer-specific diagnosis is a hypothesis until the proposed change is tested. It may explain the labeled incident yet introduce a regression in neighboring cases. Historical replay supplies the missing validation step. Historical replay must establish whether the intervention repairs the failure without relying on success that would have occurred anyway.
ReplayRCA formalizes that distinction by restoring the environment to the state immediately before the chosen step. The proposed action replaces the agent’s action, after which the original agent continues. A paired placebo replays the original action through the same mechanism, allowing the causal repair score to subtract success unrelated to the fix.
AgentDebugX turns the same discipline into a Detect → Attribute → Recover → Rerun workflow. Recovery converts the diagnosis into a concrete retry directive, and rerunning applies the approved correction from an appropriate checkpoint while retaining both branches for comparison. Production traces that fail a scorer can then become eval cases automatically, keeping the incident as a future regression test. Replay validation gives harness engineering the discipline that code review and testing give software engineering.
Before integrating a fix, the concrete gate is a three-set replay check. Golden cases must keep baseline behavior, adversarial cases must show that the change adds no new vulnerabilities, and the affected production slice must show that the original failure class has been fixed.

Sources
- Root-Cause Attribution Is a Search Problem: Continual Search for Long-Horizon Agent Failures
- TelemetrySuffBench: Is Agent Telemetry Sufficient for Failure-Origin Diagnosis?
- AgentDebugX: An Open-Source Toolkit for Failure Observability, Attribution, and Recovery in LLM Agents
- ReplayRCA: Measuring Post-hoc Diagnosis and Live Oversight of Agent Failures by Counterfactual Replay


