NeurIPS 2026Coming to NeurIPS?Explore papers, orals & directions

Explaining Agent Behavior with Large Language Models

Xijia Zhang, Yue Guo, Simon Stepputtis, Katia P. Sycara, Joseph CampbellarXiv 2023 · DOI

Introduction

As autonomous agents, such as robots and self-driving vehicles, are increasingly deployed in safety-critical environments, understanding the rationale behind their decisions becomes paramount. Most high-performing agents today are powered by Deep Neural Networks (DNNs), which function as "black boxes," offering little transparency into their internal logic. This lack of interpretability poses a significant barrier to human trust and safety.

Existing Explainable AI (XAI) methods typically fall into two categories: rigid, template-based systems that feel robotic and limited, or methods requiring deep access to a model's internal weights. While Large Language Models (LLMs) offer a promising avenue for generating natural language explanations, they are notoriously prone to "hallucination"—generating factually incorrect but plausible-sounding justifications. The challenge lies in providing LLMs with sufficient context to explain a black-box model accurately and interactively without compromising the agent's performance.

Methodology

Zhang et al. propose a model-agnostic framework that interprets agent behavior (states and actions) without requiring access to the underlying code. The process is structured into a three-stage pipeline:

  1. Policy Distillation: The complex DNN policy is distilled into a decision tree. While the original DNN is opaque, the decision tree provides a transparent, symbolic flowchart that approximates the agent's behavior.
  2. Behavior Representation (BR) Generation: When an explanation is required for a specific action, the system extracts the corresponding "decision path" from the tree. This path (e.g., "If room is explored AND no victim is present -> Move East") serves as a grounded, symbolic representation of the agent's reasoning.
  3. In-Context Learning: This decision path is converted into text and used as a prompt for a pre-trained LLM (specifically GPT-4). By reasoning over this "ground truth" logic, the LLM crafts a natural language explanation that is both grounded and interactive.
The three-stage framework: Policy Distillation, Local Explanation Generation, and Interactive Explanations.

This framework allows for interactive queries, enabling users to ask follow-up questions or explore counterfactual scenarios, such as "What if that room had rubble?"

Experimental Setup

The framework was evaluated in a Multi-agent Urban Search and Rescue (USAR) environment. This 2D grid-world (4x5 rooms) contained victims to be rescued and rubble to be cleared. Two distinct agents were used: a "Medic" for rescues and an "Engineer" for clearing rubble, both controlled by reinforcement learning policies. To assess the quality of the generated explanations, the authors conducted an IRB-approved human-subject study with 32 participants, comparing the LLM-generated output against human-expert explanations and template-based baselines.

Results and Discussion

The study yielded several key insights into the effectiveness of the proposed framework:

  • Human-Level Quality: In head-to-head comparisons, participants rated the framework's explanations as significantly more helpful than template-based ones and at least as helpful as those written by human domain experts.
  • Hallucination Control: The use of a "Decision Path" as a logical anchor significantly reduced factual errors. Baselines that provided only raw state information or no behavior representation at all were far more likely to produce hallucinations.
  • The Value of Interaction: Interestingly, the study found that interaction is most valuable when an agent performs sub-optimally. While users found explanations for optimal behavior straightforward, the ability to ask "why" when an agent failed (e.g., missing a victim) was critical for building trust.
Human preference results comparing the proposed LLM-based explanations against template-based and human-expert baselines.

Conclusion and Future Work

This research demonstrates that distilling black-box policies into symbolic representations allows LLMs to generate high-quality, grounded explanations. However, limitations remain. Scaling this approach to high-dimensional, continuous spaces like real-world robotics will require more advanced distillation techniques. Furthermore, the explanation's accuracy is inherently tied to the fidelity of the surrogate decision tree; if the tree fails to capture the DNN's nuances, the explanation may be "faithfully explaining a slightly wrong model." Future work will focus on these scaling challenges and the long-term impact of interactive explanations on human-AI trust.

Summary updated

BibTeX
@misc{zhang2023explaining,
  author = {Xijia Zhang and Yue Guo and Simon Stepputtis and Katia P. Sycara and Joseph Campbell},
  title = {{Explaining Agent Behavior with Large Language Models}},
  year = {2023},
  eprint = {2309.10346},
  archivePrefix = {arXiv},
  url = {https://arxiv.org/abs/2309.10346},
}
Figure