TRAJDEBUG: Tracing Error Lifecycle to Identify Critical Failures in Long-Horizon Agent Trajectories

Yunjia Qi, Zehua Yin, Xintong Shi, Hao Peng, Songyuanyi Lu, Yixian Liu, Richeng Xuan, Yuhong Liu, Zhichao Hu, Xiaozhi Wang, Lei Hou, Bin Xu, Juanzi LiarXiv 2026

TL;DR

TRAJDEBUG is a novel framework designed to find the exact "root cause" error in failed, long-horizon LLM agent trajectories. By compressing long histories and tracing the lifecycle of individual mistakes—separating harmless or self-corrected errors from terminal ones—it significantly outperforms standard prompting methods and provides actionable feedback to improve future agent performance.

What Problem Does This Paper Address?

Large Language Model (LLM) agents are increasingly deployed on complex, multi-step tasks like software engineering or multi-turn customer service. However, when an agent fails after a sequence of 100+ steps, debugging it is incredibly difficult.

The authors identify two core challenges in critical error detection (finding the earliest decisive mistake that doomed the trajectory):

  1. Distant Evidence: The clue showing that a step was a mistake is often scattered across far-away instructions, environment observations, or prior context.
  2. Coexisting Local Errors: Failed trajectories are messy. They often contain multiple minor or local errors. Crucially, many of these errors are later fixed by the agent or turn out to be completely harmless, obscuring the single critical error that actually caused the final failure.
Figure 1: Critical error detection requires grounding er- rors in long-range context and distinguishing the failure- responsible error from multiple coexisting errors.

Methods

TRAJDEBUG breaks down the holistic, error-prone task of debugging into a structured, three-stage pipeline:

  1. Multi-Granularity Compression: To fit long trajectories into LLM context windows without losing vital details, the framework creates three parallel views for each step: high-detail (exact actions/observations), medium-detail (summarized intents/state updates), and low-detail (coarse progress).
  2. Error Trigger Detection: The system scans the trajectory step-by-step to find atomic "error triggers" where the agent's commitments conflict with the task instructions, history, or internal reasoning. To prevent hallucinations, every trigger must satisfy a verbatim evidence condition—meaning the conflict must be explicitly citable from the text.
  3. Error State Classification: Triggers are clustered into object-anchored "error instances." TRAJDEBUG then tracks their lifecycle to see if they were later resolved or if they left a "terminal footprint" (e.g., an irreversible state change or wasted budget). It filters out benign or corrected errors, leaving only terminal-relevant candidates.
  4. Causal Attribution: Finally, an LLM selects the true critical error from this refined candidate set based on which mistake best explains the ultimate failure.
Figure 3: An overview of the framework of TRAJDEBUG.

Datasets

The authors evaluated TRAJDEBUG on several existing agent benchmarks, including WhoAndWhen and AgentDebugBench (which span ALFWorld, GAIA, and WebShop).

To test the framework in more realistic, long-horizon settings, they introduced TRAJERRBENCH, a new benchmark consisting of 486 manually annotated failed trajectories:

  • 400 trajectories from $\tau^2$-Bench (complex tool-use and customer service workflows).
  • 86 trajectories from SWE-Bench Pro (long-horizon software engineering tasks averaging ~120 steps per trajectory).

Key Insights and Ideas

  • Longer Trajectories Breed More Distractions: The authors' pilot study revealed that as trajectory length grows, the density of non-critical local errors increases dramatically, while standard LLM accuracy in finding the root cause plummets (see Figure 2).
  • Agents Self-Correct More Than You Think: Out of 331 non-critical local errors analyzed, 61.9% were eventually repaired by the agent later in the execution. This proves that simply picking the first error in a log is a poor strategy for root-cause analysis.
  • Critical Errors Happen Late: In realistic benchmarks like $\tau^2$-Bench and SWE-Bench Pro, critical errors predominantly occur in the mid-to-late stages of a trajectory, usually during the reasoning phase after the agent has spent many steps gathering information (see Figure 4).
Figure 2: Critical error detection accuracy and local error density across trajectory length buckets.

Key Results

  • State-of-the-Art Diagnostic Accuracy: TRAJDEBUG achieved the highest macro-average accuracy (34.11%) across seven distinct datasets, outperforming advanced frontier models (like Gemini-3.1-Pro and Claude Sonnet 4.6) using direct prompting, as well as specialized multi-agent debugging baselines.
Main results table across benchmarks
  • Robustness to Length: While baseline models saw their accuracy drop below 15% on trajectories longer than 140 steps, TRAJDEBUG remained stable, maintaining over 20% accuracy due to its evidence-grounded filtering (see Figure 5).
  • Actionable Feedback for Improvement: When TRAJDEBUG's diagnoses were turned into natural language hints and fed back to the agent, it boosted the agent's success rate by 10.80% on a retry of the same task, and by 5.70% when transferred to completely unseen tasks via a "failure memory pool."

Limitations and Future Work

Despite its staged pipeline, TRAJDEBUG still relies on an underlying LLM for the final interpretation and causal attribution of errors, meaning its performance is bound by the model's baseline reasoning capacity. Additionally, if the early stages suffer from a false negative and miss an error trigger, the true critical error will be excluded from the final candidate set.

To mitigate this, the authors implemented an "out-of-set fallback mechanism" that allows the model to predict a missing trigger under strict evidence constraints, but improving the initial recall for subtle, nuanced errors remains an open direction for future work.

Summary updated

BibTeX
@misc{qi2026trajdebug,
  author = {Yunjia Qi and Zehua Yin and Xintong Shi and Hao Peng and Songyuanyi Lu and Yixian Liu and Richeng Xuan and Yuhong Liu and Zhichao Hu and Xiaozhi Wang and Lei Hou and Bin Xu and Juanzi Li},
  title = {{TRAJDEBUG: Tracing Error Lifecycle to Identify Critical Failures in Long-Horizon Agent Trajectories}},
  year = {2026},
  eprint = {2608.06346},
  archivePrefix = {arXiv},
  url = {https://arxiv.org/abs/2608.06346},
}
Figure