TL;DR
TalkToAgent is a multi-agent Large Language Model (LLM) framework that turns black-box Reinforcement Learning (RL) policies into interactive, domain-grounded explanations. By combining five specialized agents with standard Explainable RL (XRL) tools and simulation, it translates natural language queries into feature attributions, decomposed future outcomes, and novel behavior- or policy-level contrastive comparisons.
What Problem Does This Paper Address?
Deep RL agents make complex sequential decisions that are notoriously opaque, making them difficult to trust in safety-critical domains like process control. While various Explainable RL (XRL) techniques exist—such as feature saliency or outcome forecasting—domain experts often don't know which method to pick, struggle to interpret technical visual outputs, and find existing contrastive explanations ("Why action A instead of B?") limited to rigid, single-step action swaps.
TalkToAgent addresses this gap by providing an end-to-end, natural language interface that selects the right XRL tool, runs forward simulations, and translates technical plots into plain English contextualized within the physical system.
Methods
TalkToAgent coordinates five specialized LLM agents (implemented by default using OpenAI's GPT-4.1) working alongside pre-built Python explanation tools:
- Coordinator: Parses user intent, selects the correct XRL tool, and extracts arguments (including numerical time spans and action values).
- Coder: Automatically writes executable Python code for decomposing reward functions or defining custom rule-based contrastive policies.
- Evaluator: Inspects generated trajectories to detect hallucinations or deviations from user intent.
- Debugger: Takes error traces and evaluator critiques to provide iterative feedback until generated code runs successfully.
- Explainer: Synthesizes visualizations and rollout statistics into concise, domain-grounded text.
User Query ──> [Coordinator] ──> Selects XRL Tool / Dispatches Code Tasks
├──> [Coder ⇄ Debugger ⇄ Evaluator] (Iterative Code Gen)
└──> Execution & Simulation ──> [Explainer] ──> Multimodal Output
The system supports three major XRL explanation categories:
- Feature Importance (FI): Computes state attributions using DeepSHAP to explain instantaneous actions.
- Expected Outcomes (EO): Decomposes Q-values temporally (via simulator rollouts) and component-wise (using auto-generated sub-reward code).
- Extended Contrastive Explanations (CE):
- Action-based (CE-A): Sustained action interventions over specified time windows.
- Behavior-based (CE-B): Maps qualitative descriptions (e.g., "aggressive", "conservative", or "opposite") to trajectory smoothing factors ($\alpha$) using Polyak averaging.
- Policy-based (CE-P): Synthesizes and executes alternative rule-based controllers (e.g., on-off control) to benchmark against the RL agent.
Datasets
- Quadruple-Tank Process Control Benchmark: A classic nonlinear, multivariable control benchmark simulated via the
pc-gympackage. The system features two pumps controlling water levels across four interconnected tanks exhibiting strong hydraulic coupling and non-minimum phase ("inverse response") dynamics. - RL Policy: A Soft Actor-Critic (SAC) agent trained with Stable-Baselines3 over $10^6$ steps to track varying level setpoints.
- Evaluation Queries: A curated benchmark of 90 natural language queries covering FI, EO, CE-A, CE-B (20 queries each), and CE-P (10 queries).
Key Insights and Ideas
- Closing the loop with coder-evaluator-debugger teams: Generating executable code on the fly for complex control tasks frequently causes broadcasting or dimension mismatches (
ValueError) and policy logic hallucinations. An evaluator paired with a targeted debugger agent prevents the model from getting stuck in recurring error loops. - Bridging qualitative language and control parameters: Operators intuitively speak in control tendencies—asking what happens if the policy acts "conservatively" or "aggressively." Parameterizing these terms via exponential trajectory smoothing factors ($\alpha$) allows LLMs to ground qualitative behavioral intuition into quantitative rollouts without retraining.
- Demystifying counter-intuitive physics: In coupled systems, an action that seems intuitive (e.g., counteracting a dip in Tank 1) often exacerbates errors in Tank 2 due to physical coupling. TalkToAgent successfully highlights these trade-offs in its multimodal explanations.
Key Results
- Task Routing Accuracy: GPT-4.1 achieved 97.5% task classification accuracy in few-shot settings (and 96.6% zero-shot), correctly identifying the appropriate XRL tool and achieving 100% accuracy in extracting function arguments.
- Robust Code Generation: Without the debugger, policy code synthesis often failed or cycled repeatedly on array dimension errors. The coder-evaluator-debugger loop drastically reduced total failures and attempt counts across repeated runs.
- Qualitative Clarity: Across tested scenarios, the Explainer generated concise (<200 token) explanations that correctly diagnosed coupled system effects, such as explaining how an "opposite control" counterfactual briefly helped one tank but destabilized the overall system.
Limitations and Future Work
- Local vs. Global Scope: The framework is currently restricted to local explanations (specific state-action pairs or time intervals) rather than explaining global, policy-wide strategy.
- Simulator Dependency: Forward trajectory simulation and expected outcome estimation require an environment model or simulator, which may not always be available in black-box real-world setups.
- Contrastive, Not Fully Counterfactual: Users must explicitly suggest the alternative action, behavior, or policy. The authors highlight extending this to true outcome-driven counterfactual inference (e.g., automatically discovering what action sequence would have prioritized a specific sub-reward) as an important next step.
Summary updated