TRAJDEBUG is a framework designed to identify the specific, earliest error in a long-horizon agent trajectory that causes a final task failure. By tracing the lifecycle of errors—from their initial trigger to their downstream impact—the system helps developers pinpoint why an agent failed, rather than getting lost in the multiple, often inconsequential, mistakes that occur during complex tasks.
The Challenge of Long-Horizon Debugging
LLM-based agents often perform hundreds of steps involving planning, tool use, and environment feedback. When these agents fail, identifying the root cause is difficult because evidence is scattered across distant instructions and observations. Furthermore, trajectories often contain many "local" errors—some are fixed by the agent, some are harmless, and others are merely symptoms of a deeper issue. Existing methods often struggle to distinguish these minor mistakes from the single, critical error responsible for the final failure.
How TrajDebug Works
The framework processes trajectories in three distinct stages:
Multi-Granularity Compression: To manage long contexts, the system creates three views of each step: high-detail (for local verification), medium-detail (for intent and action), and low-detail (for coarse progress). This allows the model to maintain necessary evidence while keeping the overall context manageable.
Error Trigger Detection: The system identifies "triggers," which are mismatches between the agent's actions and task instructions, history, or environment feedback. Each trigger must be supported by citable evidence to prevent the model from hallucinating errors.
Lifecycle Classification: Related triggers are grouped into "error instances." The system then classifies these instances based on whether they were resolved or if they left a "terminal footprint," such as an irreversible state change or a persistent violation. Only instances that remain relevant to the final failure are passed to the final stage for causal attribution.
TrajErrBench: A New Benchmark
To evaluate the system, the researchers introduced TrajErrBench, a dataset of 486 manually annotated failed trajectories. This benchmark includes 400 cases from τ2-Bench and 86 cases from SWE-Bench Pro, covering diverse scenarios like tool use and complex software engineering tasks. The average length of the SWE-Bench Pro trajectories is approximately 119.7 steps, providing a rigorous test for long-horizon error detection.
Results and Practical Application
Experiments show that TrajDebug outperforms existing prompting baselines and diagnostic systems in identifying critical errors. Beyond simple diagnosis, the researchers tested the framework in two practical scenarios:
Targeted Guidance: Using diagnoses to provide feedback before re-executing a task improved success rates by 10.80% on average.
Failure Memory: Aggregating diagnoses from historical failures into a reusable memory bank for new tasks yielded a 5.70% average improvement.
These findings suggest that TrajDebug functions as both a diagnostic tool and a method for converting past failures into actionable experience for future agent performance.
Comments (0)
to join the discussion
No comments yet
Be the first to share your thoughts!