SAFARI: Scaling Long Horizon Agentic Fault Attribution via Active Investigation

Chenyang Zhu, Jiayu Yao, Kushal Chawla, Youbing Yin, Nathan Wolfe, Pengshan Cai, Jingyu Wu, Spencer Hong, Sangwoo Cho, Shi-Xiong Zhang, Daben Liu, Sambit Sahu, Erin Babinsky

TL;DR

SAFARI is a new framework designed to find the "root cause" of failures in autonomous AI agents, even when their execution logs are millions of tokens long. Instead of forcing an LLM to read a massive trajectory all at once—which often leads to "forgetting" or hitting context limits—SAFARI uses an Active Investigator loop that strategically searches, reads, and reasons over specific log segments. It maintains a persistent short-term memory to track its "detective work," allowing it to accurately identify faults even when they occur 5x further back than the model’s native memory limit.

What Problem Does This Paper Address?

As AI agents become more capable, they perform increasingly complex, multi-step tasks. The "trajectories" (logs of every action and observation) for these tasks are exploding in size, sometimes reaching millions of tokens.

When these agents fail, we need to perform fault attribution: identifying exactly which step or agent was responsible for the eventual collapse. Current state-of-the-art methods typically use a "judge" LLM to read the entire trajectory and spot the error. However, this approach faces two major hurdles:

  1. Context Limits: Even the most advanced models (like Claude 3.5 or GPT-4o) have a maximum "window" of text they can process at once.
  2. Attention Dilution: Even if the text fits, LLMs often struggle to find a "needle in a haystack" when buried under hundreds of thousands of words of irrelevant logs.

Methods

The authors introduce SAFARI (Scaling long-horizon Agentic Fault AttRibution via active Investigation). Rather than a passive, one-shot reading of the log, SAFARI treats fault attribution like a forensic investigation.

Key components include:

  • The Investigator Agent: An LLM equipped with a "toolbox" to interact with the trajectory.
  • Specialized Tools:
    • read(offset, limit): Allows the agent to "scroll" through specific sections of the log.
  • search(pattern): Uses regex to "jump" to specific error messages, variable names, or step IDs.
  • Short-Term Memory (STM): A persistent JSON block that tracks the task goal, current hypotheses, evidence gathered, and future plans. This is crucial because as the conversation history grows, the oldest parts are deleted; the STM ensures the agent doesn't "forget" its own progress.
  • Atomic Reasoning Evaluator: Before finalizing a conclusion, the agent must break its hypothesis into "atomic claims" (e.g., "Step 5 failed because X happened"). A separate evaluator LLM verifies these claims against specific quoted evidence. If the confidence score is too low, the investigator must go back and find better proof.

Datasets

The researchers evaluated SAFARI on two primary benchmarks:

  1. Who&When: A dataset featuring traces from multi-agent systems like Magentic-One and CaptainAgent. It includes both algorithm-generated and hand-crafted (more complex) trajectories.
  2. TRAIL: A benchmark for long-horizon agentic issue localization, specifically the GAIA (general assistant tasks) and SWE-bench (software engineering) subsets. Some trajectories here exceed 2 million tokens.

Key Insights and Ideas

  • Active > Passive: The most significant insight is that active investigation (searching and retrieving) is far more robust than passive ingestion (reading everything). By decoupling the diagnostic process from the model's context window, SAFARI can handle virtually any trajectory length.
  • The "Scaling Factor" (ς): The authors formalize the challenge using ς, the ratio of the fault's position to the model's context limit. While traditional judges fail when ς > 1 (the fault is outside the window), SAFARI remains effective.
  • Memory as a Logical Anchor: The STM isn't just a summary; it acts as a "logical anchor" that preserves investigative intent. This prevents the agent from getting stuck in loops or repeating tool calls.
  • Precision over Recall: By enforcing a verification stage with an "Atomic Reasoning Evaluator," the system prioritizes high-confidence, evidence-backed conclusions over guesses.

Key Results

  • Outperforming the State-of-the-Art: SAFARI outperformed previous methods (like RAFFLES) by 20% on the Who&When benchmark and by 19% on the TRAIL GAIA subset.
  • Breaking the Context Barrier: Most impressively, SAFARI maintained a 0.58 precision even when the target fault was 5x beyond the model's native context window—a scenario where traditional "one-shot" evaluators score zero because they literally cannot see the data.
  • Efficiency: SAFARI with a tiny 100k token budget achieved performance comparable to state-of-the-art models using a 1M token budget, proving it is a much more cost-effective way to debug long-running agents.

Limitations and Future Work

  • Latency: Because SAFARI is iterative (it takes multiple "turns" to investigate), it is naturally slower than one-shot methods. In low-budget scenarios, it intentionally trades time for accuracy.
  • Code-Heavy Traces: The authors noted that code-heavy logs (like those in SWE-bench) are harder to condense into the STM than general-purpose agent logs, leading to slightly lower performance in those specific domains.
  • Conflicting Information: Future research is needed to see how the agent handles situations where the raw logs and the summarized STM might provide conflicting signals.
  • Generalization: The authors plan to test if this "Active Investigation" loop can be applied to other long-horizon tasks beyond just finding faults, such as open-ended reasoning or creative synthesis.

Summary updated

BibTeX
@inproceedings{zhu2026safari,
  author = {Chenyang Zhu and Jiayu Yao and Kushal Chawla and Youbing Yin and Nathan Wolfe and Pengshan Cai and Jingyu Wu and Spencer Hong and Sangwoo Cho and Shi-Xiong Zhang and Daben Liu and Sambit Sahu and Erin Babinsky},
  title = {{SAFARI: Scaling Long Horizon Agentic Fault Attribution via Active Investigation}},
  booktitle = {AIWILD @ ICML},
  year = {2026},
  url = {https://openreview.net/forum?id=tXVNXhps8B},
}
Figure