TalkToAgent: A Human-centric Explanation of Reinforcement Learning Agents with Large Language Models

Haechang Kim, Hao Chen, Can Li, Jong Min Lee · DOI

Abstract

Deep Reinforcement Learning (DRL) has achieved remarkable success in complex control tasks, yet its "black-box" nature remains a significant barrier to adoption in safety-critical domains. We present TalkToAgent, a multi-agent Large Language Model (LLM) framework designed to bridge the comprehensibility gap between raw Explainable RL (XRL) outputs and the practical needs of domain experts. By orchestrating five specialized agents, the system translates natural language queries into actionable insights, mapping user questions to specialized explainability tools and generating "what-if" scenarios through automated code generation. Our evaluation on a nonlinear control benchmark demonstrates high intent mapping accuracy and robust explanation generation.

Introduction

While various XRL tools—such as saliency maps or reward decomposition—exist, they are often fragmented and require significant expertise to interpret. A domain engineer might ask, "Why did the agent suddenly drop the pump voltage?" or "What would happen if the agent acted more conservatively?" Current methods struggle to answer these qualitative, human-centric questions. TalkToAgent addresses this by providing a unified interface that supports a wider range of explanation modalities than previous studies.

Comparison of TalkToAgent with previous XRL studies across various explanation modalities, including Feature Importance (FI), Expected Outcomes (EO), and multiple Counterfactual (CF) types.

The TalkToAgent Framework

The core of TalkToAgent is a multi-agent architecture consisting of five specialized LLM roles that automate the explanation pipeline:

  1. Coordinator: Acts as the "router," interpreting user intent to select the appropriate XRL tool.
  2. Explainer: The "narrator" that translates raw data and visualizations into domain-specific natural language.
  3. Coder: Generates Python code for custom reward functions or rule-based counterfactual policies.
  4. Evaluator: Validates that the generated code correctly implements the user's request without logic hallucinations.
  5. Debugger: Analyzes execution errors to provide iterative refinement instructions to the Coder.
The multi-agent architecture of TalkToAgent, illustrating the interaction between specialized LLM agents, generated code, and predefined XRL tools.

Supported XRL Perspectives

The framework supports three primary perspectives:

  • Feature Importance (FI): Utilizes DeepSHAP to identify which state variables (e.g., tank levels) influenced specific actions.
  • Expected Outcomes (EO): Decomposes Q-values to illustrate how the agent prioritizes different objectives over time.
  • Counterfactuals (CF): Supports Action-based (single-step), Behavior-based (simulating "aggressive" vs. "steady" behavior), and Policy-based (generating new rule-based controllers) scenarios.

Experimental Setup

The framework was validated using the quadruple-tank process control system, a nonlinear control benchmark. The environment involves four interconnected tanks where the goal is to maintain specific water levels despite strong coupling. A Soft Actor-Critic (SAC) agent was trained using Stable-Baselines3 and the PC-gym simulation package to serve as the subject of explanation.

Key Results and Insights

  • High Intent Accuracy: The Coordinator achieved a 96.7% mapping accuracy (using GPT-4.1) in correctly identifying the appropriate XRL tool from natural language queries.
  • Robust Code Generation: The iterative loop between the Coder, Evaluator, and Debugger significantly reduced failures, allowing the system to self-correct and produce valid counterfactual policies that single-agent setups could not reliably generate.
  • Context-Aware Interpretation: By incorporating system descriptions and environment parameters into prompts, the Explainer provided meaningful engineering insights (e.g., explaining "inverse responses" where an agent moves a variable in the "wrong" direction for long-term stability) rather than generic data descriptions.

Conclusion and Future Work

TalkToAgent demonstrates the potential of multi-agent LLM systems to make RL policies accessible to non-experts. Future work will focus on "result-oriented" queries, where users specify desired outcomes (e.g., "minimize energy use") rather than specific actions. Additionally, we aim to expand the Coder agent's capabilities to generate more complex control structures, such as Model Predictive Control (MPC), and validate the framework across diverse domains like finance and autonomous driving.

Summary updated

BibTeX
@misc{kim2025talktoagent,
  author = {Haechang Kim and Hao Chen and Can Li and Jong Min Lee},
  title = {{TalkToAgent: A Human-centric Explanation of Reinforcement Learning Agents with Large Language Models}},
  year = {2025},
  eprint = {2509.04809},
  archivePrefix = {arXiv},
  url = {https://arxiv.org/abs/2509.04809},
}
Figure