Manuscript Offprint

arXiv:2609.02371

Diagnosing with Insights: Structured Analysis of Agent Failures via Behavioral Abstractions

Jiayi Bi, Yanjie Gao, Yuanmin Xie, Liqun Li, Tianyin Xu, Fan Yang, Mao Yang

Open access. PaperVantage converted this article to text, so layout and figures may differ from the original.

ABSTRACT

With the proliferation of LLM agents, the ability to understand and diagnose failures in agents is essential to achieving superior effectiveness and trustworthiness. As agent failures often manifest via long and complex trajectories, manually finding the needles in the haystack is untenable. However, traditional diagnosis techniques for software bugs can hardly address LLM agent failures, while completely relying on LLMs as the judge yields unreliable diagnosis results. To overcome these challenges, this paper presents AGENTSCOPE, a new neuro-symbolic approach for agent failure mode diagnosis. The key principle of AGENTSCOPE is to abstract agent behavior, based on its trajectories, into structured representations. Furthermore, AGENTSCOPE introduces the concept of neural invariants to specify agent behavior properties. AGENTSCOPE leverages LLM-guided reasoning atop the structured representation against neural invariants to pinpoint both the failure step and its type in the trajectory. We show the effectiveness of AGENTSCOPE on publicly available agent failure datasets (Who&When) and a more comprehensive dataset created by us (AgentErrata), where AGENTSCOPE significantly outperforms the current art in fault localization and attribution accuracy. Our work shows that integrating structured abstractions with LLM-guided reasoning enables effective, reliable, and interpretable diagnosis for agent failures.

1 INTRODUCTION

Recent advances in Large Language Models (LLMs) have been driving active development of LLM agents that autonomously interact with tools and environments using natural languages. For example, agents can issue API calls, synthesize code, query databases, and cooperate with other agents to solve complex and multi-step tasks. Modern agent frameworks such as LangChain (Chase, 2022), Auto-GPT (Significant Gravitas), and OpenManus (Liang et al., 2025) orchestrate multi-step interactions, allowing agents to operate in open and dynamic environments.

Despite their exciting capabilities, LLM agents are known to fail in subtle and sophisticated ways (Cemri et al., 2025; Zhang et al., 2025c; Skalse et al., 2022; Bryan et al., 2025; Baker et al., 2025; Fu et al., 2025). Failures can occur at any step during the agent's reasoning (e.g., the chain of thoughts) and action execution (e.g., tool calls), cascade along the agent runtime behavior, and eventually manifest as specific mistake behavior or even disrupt task execution. Thus, the ability to understand and diagnose failures in agents is essential to achieving superior effectiveness and trustworthiness of agent systems. Unfortunately, as agent failures often manifest through prolonged and complex trajectories composed of numerous steps with accumulating context, manually finding needles in the haystack is slow, costly, and obviously untenable.

This work was done during Jiayi's internship at Microsoft Research and Yuanmin's internship at Microsoft. †Corresponding author.

Worse still, traditional diagnosis techniques for software bugs can hardly address LLM agent failures Zeller (2009); Attariyan & Flinn (2010); Yuan et al. (2010); Zhang et al. (2019); Ren et al. (2023). The fundamental reason is that traditional techniques are confined to symbolic and logical analysis of software codes and program executions. In contrast, agent failures are often rooted in faulty reasoning errors, invalid contexts, or instruction-unfollowing behaviors across multiple steps, which involve the entanglement of fuzzy neural paradigms and rigid symbolic paradigms.

Recent studies (Zhang et al., 2025c; Cemri et al., 2025; Zhu et al., 2025; dlshriver, 2023) have proposed several neural approaches for agent failure analysis—prompting or fine-tuning LLMs with failure trajectories and asking them to identify root causes. However, our experiments show that sole LLM-based approaches often produce unreliable and incomplete diagnostic results. Even the best-performing model, GPT-5.1 (Singh et al., 2025), achieves only 18.15% accuracy on our failure attribution datasets (see Section 5.2). The cause of this limitation is that LLMs, even when fine-tuned, struggle to systematically capture multi-step reasoning and action behaviors and maintain consistent causal invariants. Thus, they are prone to confusing correlated symptoms with true causes and sensitive to contexts and instructions.

This paper presents AGENTSCOPE, a novel neuro-symbolic framework for diagnosing agent failures. The key idea of AGENTSCOPE is to abstract the agents' behavior from their trajectories into a structured representation, termed the Reasoning-Action Graph (ReAG), that encapsulates both the reasoning and action execution steps of the agents, enabling rigorous correctness reasoning using formally defined invariant violation conditions on their behaviors. Different from traditional program invariants (Hoare, 1969), AGENTSCOPE introduces the concept of neural invariants, which can be specified with neural functions to encode correctness conditions; checking such invariants requires LLM-guided reasoning. We show that LLM-guided reasoning atop structured behavior abstractions enables AGENTSCOPE to effectively diagnose the causes of the agent failure. Compared with existing vanilla LLM-as-a-judge approaches, AGENTSCOPE demonstrates stronger diagnosis ability and more interpretable results. It can accomplish both failure localization and failure attribution: the former pinpoints the root-cause step and the latter predicts the failure category.

We evaluated AGENTSCOPE on a publicly available agent failure dataset named Who&When (Zhang et al., 2025c) and a new dataset called AgentErrata created by us through failure-taxonomy-guided fault injection for more comprehensive evaluation. Results show that AGENTSCOPE achieves significant improvements in accuracy and interpretability over state-of-the-art approaches, with localization accuracies ranging from 25.40% to 77.78% on the Who&When Algorithm-Generated dataset and from 22.41% to 34.48% on the Who&When Hand-Crafted dataset, along with enhanced attribution interpretability. Moreover, AGENTSCOPE also outperforms other methods on our new dataset, AgentErrata, achieving accuracies ranging from 28.38% to 54.13%.

In summary, we make the following contributions:

  • Principle. We show that LLM-guided reasoning atop structured representations of behavior abstractions can significantly improve agent failure diagnosis ability.
  • Concept. We introduce the concept of neural invariants, which use neural functions to formally define and detect properties of agent misbehaviors.
  • Tooling. We develop AGENTSCOPE, a practical runtime framework and toolchain for agent failure detection and diagnosis that is integrated with modern agent frameworks.
  • Dataset. We create AgentErrata, a new benchmark dataset for agent failures. Generated through a failure-taxonomy-guided fault injection process, it contains a comprehensive set of failure types covering diverse agent misbehaviors.
  • Evaluation. We present the utility of AGENTSCOPE using systematic evaluations and showcase its improved accuracy and interpretability over the current art.

References (50)