A Decision Tree for Pinning an LLM Agent Failure to Prompt Tool or Workflow Without Guesswork
A trace-based decision tree for blaming the right harness layer.

AI agent failure attribution by harness layer starts with a complete production trace and follows the decisive error back to the prompt, tool, or workflow that introduced it. The method is to test trace evidence against each layer’s failure signature, distinguish critical errors from harmless or repaired ones, and validate the proposed fix through replay. A visible failure is the starting point for diagnosis.
Why agent failures resist intuitive debugging
An agent returns a wrong answer after many apparently reasonable steps because its planner dropped a required constraint near the start. The final response exposes the problem but does not locate it. AgentDebugX (Zhu et al., 2026) describes this separation between the step where an error surfaces and the step that caused it. An omitted planning constraint, stale memory retrieval, invalid intermediate assumption, or incorrect handoff can propagate through later decisions before becoming visible. Fixing the final response leaves that earlier cause untouched.
TRAJDEBUG (Qi et al., 2026) distinguishes errors that are repaired, errors that remain harmless, and errors that remain responsible for the outcome. Who&When Pro (Liu et al., 2026) finds that LLMs evaluating traces tend to blame the most visible symptom, often a reasoning step, rather than an originating planning or verification failure. Visibility is not the same as causal responsibility.
The harness as the structure that contains most failures
A production agent consists of a model surrounded by a harness, where most attributable failures originate. That harness includes prompt templates, permitted tools, memory or retrieved context, planning and revision logic, and output verification. For diagnosis, these components form three practical layers, namely prompt, tool, and workflow. The prompt layer specifies the task and agent roles. The tool layer governs calls and responses, while the workflow layer governs sequencing, handoffs, and coordination.
These boundaries make an observable failure actionable. Calling something an “agent failure” identifies the system. A multi-agent system may contain separate planner, router, tool-use, reviewer, and sub-agent prompts, each capable of failing independently. Likewise, a broken tool call may originate in the tool interface or in instructions supplied upstream. Attribution must reach the specific specification, call, or handoff responsible, and production traces make those distinctions visible.
What production traces actually contain and why they are the right instrument
Structured execution traces record model invocations, tool calls, memory reads and writes, and decision branches, linking actions to their causal antecedents through hierarchical spans. This structure exposes relationships that unstructured logs do not. Inputs, outputs, and handoffs can be read together as evidence, with links between the messages. Historical context is essential to interpreting that evidence. A call that looks right on its own may break an instruction given much earlier.
TRAJDEBUG identifies this dispersed evidence as a central attribution challenge. Judging one step may require distant instructions, observations, and prior context, so trace analysis needs history compression at multiple levels of detail. Synthetic benchmarks cannot supply the missing causal record of a particular production run. Teams that lack structured traces must first put them in place. Otherwise, the decision tree has no reliable input.
Even complete instrumentation does not perform attribution by itself. AgentDebugX distinguishes knowing what an agent did from knowing which earlier decision caused the failure. General-purpose observability platforms show what the agent did, while a diagnostic method must work out why it failed. The tree below assumes the execution record is available and uses its contents to test competing explanations.
The three failure categories and their distinguishing trace signatures
Tool failures appear when a call returns an error or malformed response, but later reasoning proceeds as though valid data arrived. The error may be ignored or replaced with a fabricated result. Schema drift leaves a similar sign: the arguments match an old API or database schema, but the environment rejects columns or parameters that are out of date. Raw errors can also be misclassified. When the harness passes a 503 or Python traceback straight into model context, the model may lack a reliable basis for deciding whether the failure is retriable.
The Buildrix case study (arXiv, 2026) illustrates the variety possible within one session. Its 105-turn agentic engineering session contained 12 failed tool calls across five categories, including data-schema mismatch, incorrect function usage, software-version incompatibility, invalid model parameters, and missing input dependencies. Those failures are in the same layer but need different fixes. The diagnostic task is to distinguish a rejected call from a parsing or error-routing failure, rather than treating every unsuccessful tool interaction alike.
Prompt / specification failures occur when tool calls are well-formed, the returned data is valid, and the steps make sense, but the run still misses the task goal. A missing constraint or poorly specified role can direct otherwise successful operations toward an unsuitable result. Prompt drift offers a less abrupt example, where a system-prompt update or tool-definition change leaves the agent running without errors while output quality deteriorates against historical baselines. The absence of a crash does not establish that the task specification is sound.
Workflow / inter-agent coordination failures appear when local steps succeed but a handoff loses context, changes format, or passes incompatible input downstream. The boundary is where the evidence becomes decisive. A planner assigning steps in YAML to an executor expecting JSON illustrates how a small interface mismatch can propagate into a broken run. Repeated read/edit cycles are another sign of a workflow failure, where the same work keeps going without coming to an end. For that loop pattern, the specified harness remedies are hash detection, a hard cap, and stripping tool_calls at the limit.
How do you pinpoint which agent layer caused a production failure?
The entry gate is trace completeness, before any layer is blamed. Every model invocation, tool call, and agent handoff needs a corresponding span with inputs, outputs, and timestamps. Coverage must extend from the initial prompt to terminal failure, including the memory activity and decision branches needed to interpret the run. Missing spans leave an observability gap. Attribution pauses there until the missing foundation is supplied.
Branch 1 tests the tool boundary. Did any tool call return an error, malformed response, or no response? If yes, the next test is whether subsequent reasoning acknowledged the failure. If not, the evidence points toward silent failure or fabrication, and the repair belongs in error-handling logic and tool response parsing. If the agent acknowledged the error but misclassified its type, the repair instead concerns the harness’s error taxonomy and routing.
Was the argument already wrong before the tool received it? If the prompt specified the format incorrectly, the investigation moves to Branch 2. If an earlier workflow step supplied the wrong data type, it moves to Branch 3. A tool rejection identifies where execution broke, but not necessarily which layer introduced the defect.
Branch 2 tests the task specification. If tool calls succeeded and returned valid data, did the output still miss the required goal? A yes leads to comparison of the system prompt with that goal, looking for an underspecified, misspecified, or omitted constraint. When the trace supports that mismatch, the prompt is the repair target.
A related test concerns task decomposition and role boundaries. If the decomposition appears correct but the agent executes the wrong sub-task, the planner prompt needs clearer boundaries and termination conditions. This remains a specification diagnosis only when the evidence supports it. If the specification is adequate and the mismatch appears during transfer or sequencing, the investigation proceeds to Branch 3.
Branch 3 tests workflow continuity. Did the steps work on their own while the multi-step or multi-agent run failed? If yes, the handoff record becomes the next evidence source, comparing the upstream output with the downstream input for differences in format, schema, or context. A mismatch identifies an interface contract that needs repair. Conflicting planner and executor outputs also belong in this coordination investigation.
The workflow branch also checks for cross-boundary propagation. A downstream failure may be inexplicable within that agent’s local trace but attributable when the upstream output is included. AgentDebugX says these cases need global trajectory understanding because local span analysis cannot explain them on its own. The unit of investigation must expand accordingly. Repeated read/edit cycles, meanwhile, call for a check of workflow termination controls when the tool keeps doing its work successfully.
Escalation begins when one pass through the trace cannot show what caused the failure. Errors may propagate, be partly repaired, and later re-emerge, so an unmatched or ambiguous trace is not grounds for assigning a layer by elimination. TRAJDEBUG has three stages: error trigger detection, error state classification, and critical attribution. The classification stage sorts errors into repaired, harmless, and critical groups before a cause is chosen. The first detected error is therefore a candidate.
For these harder cases, AgentDebugX’s DeepDebug performs multi-turn diagnosis through global trajectory understanding, structure-guided investigation, and cross-examination. It produces an auditable root-cause report with evidence and a recommended fix. LongRCA Bench (Zhang et al., 2026) offers another relevant approach through its RCTA method, which organizes original candidate records and explicit handoff instructions for attribution. Segment summaries and a trajectory outline guide candidate retrieval. These methods extend the investigation when replay alone does not establish which earlier decision was decisive.
Why the tree branches matter more for long-horizon and multi-agent traces
LongRCA Bench contains 1,140 human-annotated failed trajectories whose reference root-cause steps precede completion by a median of 48 recorded steps. More than a quarter contain over 100 subsequent steps after the decisive error. Distance makes the terminal symptom a poor diagnostic anchor. Even the strongest evaluated baseline achieves only a small fraction of exact root-step accuracy, showing why automated attribution alone is insufficient. Structured branching directs attention toward the relevant evidence without treating an automated answer as conclusive.
Long traces also have errors that later steps fix, which can distract from the cause. As a result, neither the first error nor the last suspicious step reliably identifies the critical cause. In multi-agent traces, the agent that caused the failure may be several hops across boundaries from the one that failed. Who&When Pro covers both single- and multi-agent topologies and finds that frontier LLMs still struggle with reliable attribution. Its responsible-agent metric applies specifically to multi-agent traces, where identifying the failed recipient does not necessarily identify the responsible origin.
The practical consequence is broader trace coverage with the same diagnostic standards. For long-horizon and multi-agent systems, the tree must operate at handoffs as well as inside individual spans. Multi-agent trace propagation therefore belongs in the observability infrastructure from the start. Local success cannot establish end-to-end workflow correctness.
Validating the attributed fix before shipping it
Once the responsible layer is identified, replay tests whether the proposed repair addresses it. The validation set includes the failed run that exposed the bug and a curated regression suite of runs that should still pass. A diagnosis is not yet a validated change. Prompts, tool definitions, and routing logic should be versioned artifacts with git history, so two harness versions can be diffed and A/B tested against the same historical traces.
AgentDebugX’s Rerun step turns diagnosis into an approved retry directive applied from an appropriate checkpoint. It retains the original and repaired branches for comparison, and a failed rerun sends its new trajectory back through the detection loop. Knowing where the error is makes self-correction more reliable.
After deployment, inline scorers and LLM-as-a-judge checks on live traces surface quality regressions and turn new production failures into evaluation cases. The complete loop is trace, attribute, fix, validate, and monitor. That loop makes harness engineering repeatable rather than a succession of guesses at whichever symptom appeared last.
Sources
- TRAJDEBUG: Tracing Error Lifecycle to Identify Critical Failures in Long-Horizon Agent Trajectories
- AgentDebugX: An Open-Source Toolkit for Failure Observability,
- LongRCA Bench: Root-Cause Localization in Long-Horizon Agent Trajectories
- AgentDebugX: An Open-Source Toolkit for Failure Observability, Attribution, and Recovery in LLM Agents
- Detect Before You Attribute: Cascade Failure Attribution for Multi-Agent Systems


