Understanding Your Agent: Leveraging Large Language Models for Behavior Explanation

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

Abstract

As AI agents are increasingly deployed in safety-critical environments, the need for interpretable decision-making becomes paramount. This paper introduces a framework that translates complex "black box" agent policies into clear, natural language explanations. By distilling policies into decision trees and extracting specific "decision paths," the system provides grounded context to Large Language Models (LLMs). This approach significantly reduces hallucinations and produces interactive explanations that match the quality of human experts in clarity and helpfulness.

Introduction

The deployment of deep neural networks in robotics and search-and-rescue operations has created a transparency gap. While these models perform well, their internal logic remains opaque to human operators. Existing explanation methods often rely on rigid templates or require extensive human-annotated datasets. While LLMs offer a potential solution for generating natural language, they frequently "hallucinate" when explaining agent behavior without direct access to the agent's internal logic, often assuming optimal or greedy behavior where none exists.

Methodology

The proposed pipeline consists of three core stages designed to bridge the gap between raw code and human-readable narrative:

  1. Policy Distillation: A complex, uninterpretable agent policy is distilled into a symbolic decision tree using the DAgger imitation learning algorithm. This tree acts as a simplified surrogate that mimics the original agent's behavior.
  2. Behavior Representation (BR): For any specific action, the system identifies the exact sequence of "if-then" rules (the decision path) within the tree that led to that action.
  3. LLM Prompting: This decision path is converted into text and provided to an LLM (such as GPT-4) via in-context learning. By anchoring the LLM to a specific decision path, the system generates free-form text that remains faithful to the agent's actual logic.
The three-step pipeline for generating interactive agent explanations: Policy Distillation, Behavior Representation, and LLM-based Interactive Explanations.

This architecture also supports interactive explanations, allowing users to query the agent's logic regarding counterfactual scenarios, such as how a change in the environment would alter the agent's decision-making process.

Experimental Setup and Results

The framework was evaluated in a simulated Urban Search and Rescue (USAR) environment. In this 2D Gridworld, a Medic agent and an Engineer agent must coordinate to rescue victims and clear rubble. Agents were trained with distinct strategies: exploration-focused (Explore), greedy rescue (Exploit), or fixed patterns (Fixed).

Key Findings

  • Accuracy and Grounding: The "Path-based" Behavior Representation (BR) achieved 80-90% accuracy in identifying agent strategies, significantly outperforming baselines that provided only raw state information.
  • Reducing Hallucinations: In ambiguous states where agents prioritized exploration over immediate rewards, the baseline LLM failed entirely (0% accuracy), while the BR (Path) method maintained 90% accuracy by correctly identifying the underlying logic path.
  • Human-Level Performance: In a study with 40 participants, users rated the LLM-generated explanations as being just as helpful as those written by human domain experts.
An example of the framework in action: the system extracts a decision path from the gridworld state and generates a natural language explanation and next-action prediction based on the agent's exploration strategy.

Conclusion and Future Work

Grounding LLMs with explicit decision paths effectively bridges the gap between black-box AI and human understanding. While the current method relies on symbolic inputs and memoryless decision trees, it demonstrates that providing logical context is superior to providing raw data alone. Future research will focus on scaling this approach to high-dimensional sensor data (such as video) and incorporating temporal statefulness to capture long-term agent goals.

Summary updated

BibTeX
@misc{zhang2023understanding,
  author = {Xijia Zhang and Yue Guo and Simon Stepputtis and Katia P. Sycara and Joseph Campbell},
  title = {{Understanding Your Agent: Leveraging Large Language Models for Behavior Explanation}},
  year = {2023},
  eprint = {2311.18062},
  archivePrefix = {arXiv},
  url = {https://arxiv.org/abs/2311.18062},
}
Figure