Policy-Invariant Reward Shaping from LLM Feedback: A Framework for Hybrid RL Agents
Authors: Christophe D. Hounwanou, John Emeka Eze, Yaé U. Gaba
Organizations: African Institute for Mathematical Sciences, Rwanda · AI Research and Innovation Nexus for Africa (AIRINA Labs), AI.Technipreneurs, Bénin · Sefako Makgatho Health Sciences University (SMU), South Africa · African Center for Advanced Studies (ACAS), Cameroon
Combining large language models with reinforcement learning is increasingly explored, yet the theoretical status of LLM-derived reward signals is often left implicit. We formalize the hybrid LLM-planner and RL-controller architecture as a Goal-Augmented Markov Decision Process and show that when the LLM per-state progress score is used as a bounded potential function, the resulting shaping term preserves the optimal policy set even when the LLM scores are inaccurate. This guarantee is stronger than what general LLM-as-reward approaches provide. We verify the result numerically on a small MDP under four potential configurations, including an adversarial one scaled to twenty times the base reward magnitude.
Figures & tables
Figure 1: Framework overview. Solid arrows are per-step dataflow: the environment emits state st and its caption ϕ(st) ; the LLM planner produces the active subgoal gt and a bounded potential score Φ(s,g) ; the RL policy πθ selects action at conditioned on both st and gt ; the shaping term F=γΦ(s′,g)−Φ(s,g) is added to the environment reward. Dashed arrows are periodic: the memory drives policy updates and, on the schedule of Section 4.4 , triggers plan revisions.
Φ configuration
Base V∗(s0)
Shaped V~∗(s0)
Shaped optimal policy
Matches base?
Φ≡0
0.9000
0.9000
[ s0 : forward, s1 : forward]
yes
Φ≡1
0.9000
0.7100
[ s0 : forward, s1 : forward]
yes
sign-flip
0.9000
1.4000
[ s0 : forward, s1 : forward]
yes
adversarial large
0.9000
−5.0500
[ s0 : forward, s1 : forward]
yes
Table 1: Numerical verification of Proposition 4.1 . All four Φ configurations, including one with per-state values 10–20 × the base reward magnitude, preserve the base optimal policy. The shaped value V~∗ shifts by the potential offset −Φ(s0) plus a vanishing telescope tail, as the theorem predicts.
Metric
Value
Parse rate (outputs with ≥1 subgoal)
100.0% ( 20/20 )
Mean plan length (parsed only)
8.00 subgoals
Median plan length
7 subgoals
Mean ground-truth coverage
54.8%
Mean extraneous subgoals per plan
5.30
Median tokens out per plan
37
Table 2: Planner-in-isolation audit for Qwen-2.5:14b (locally served) on 20 MiniGrid tasks. Prompt template: P1 (Appendix A ).
Config
n
Success rate
Final return
Mean steps/ep
LLM calls/seed
PPO baseline
3
28.1% [ 4.8 , 65.2 ]
0.106 [ 0.008 , 0.262 ]
340.4 [ 317.2 , 352.4 ]
0
Hybrid (Qwen)
3
9.3% [ 0.0 , 14.3 ]
0.058 [ 0.000 , 0.095 ]
348.0 [ 340.0 , 358.5 ]
30
Table 3: Pipeline validation results on MiniGrid-DoorKey-6x6. LLM budget across all runs: 92 Qwen-2.5:14b calls, 4,199 output tokens, 1.32 hours of Ollama CPU wall clock. Neither configuration converges to high success at this budget; DoorKey-6x6 typically requires roughly 5×105 environment steps for PPO convergence, whereas the pilot uses 3×104 .
Reinforcement Learning from Human Feedback (RLHF) is the standard approach for aligning large language models with human preferences, but its quality is limited by static, task-agnostic reward models. This mismatch leads to sparse learning signals and suboptimal alignment. We introduce MeRLa (Meta-Learned Reward Shaping), a principled framework that meta-learns a task-aware shaping function Φ(x,y;φ) across auxiliary tasks before RLHF training. The learned shaping produces a composite reward that preserves policy optimality while providing task-specific learning signals. Our meta-objective combines task discrimination, entropy regularization, and potential-based conservation for stable convergence. We provide theoretical guarantees for policy invariance, analyze representation drift sensitivity, and formally address incentive misalignment from entropy maximization. Experiments on LLaMA-3-8B across four benchmarks show consistent improvements over PPO, DPO, GRPO, and DAPO, achieving a 90.8% length-controlled win rate on AlpacaEval 2.0 and a score of 9.14 on MT-Bench, with 41% less training instability. MeRLa retains its benefits when combined with process-based and rubric-based enhanced rewards.
We study when large language models (LLMs) can serve as effective black-box policy optimizers for reinforcement learning (RL) tasks, i.e., when can we replace classical RL algorithms with an LLM? We explore this question by introducing Prompted Policy Optimization (PromptPO), an iterative method that prompts an LLM with Python descriptions of the state space, action space, and reward function, then has it generate and refine executable policies based on rollout feedback. Across hard exploration environments, Meta-World robotics tasks, and several real-world control problems, PromptPO often matches or exceeds the performance of standard RL baselines while using substantially fewer environment interactions. To maximize expected return, and without further explicit prompting, the policies PromptPO outputs range from tuned proportional controllers or rule-based plans to policies that run planning algorithms like value iteration. Our results demonstrate that LLM-based policy optimization is sufficient when the LLM can leverage prior knowledge about the environment or optimization strategy. PromptPO underperforms standard RL baselines in MuJoCo domains. This demonstrates possible limitations of LLM-based policy optimization to settings that requiring fine-grained continuous control.
Stephane Hatgis-Kessell, Emma Brunskill
Department of Computer Science, Stanford University
Large Language Models (LLMs) offer a natural interface for translating human objectives into reward signals for cooperative multi-agent reinforcement learning (MARL), yet the training-time dynamics of this integration remain poorly understood. We show that dynamically updating LLM-generated reward weights during off-policy MARL violates the stationarity assumption of Potential-Based Reward Shaping (PBRS) and contaminates the experience replay buffer, whose stored transitions carry reward labels computed under stale shaping weights. We characterise the result as a regime-dependent failure whose severity depends on how competent the unshaped baseline already is. To control it we propose two stabilisation strategies: a Phase-Based Freeze Schedule that enforces strict stationarity within training phases, and Exponential Moving Average (EMA) smoothing that bounds per-episode weight drift. We evaluate across three cooperative environments and five random seeds with QMIX, complemented by an exploratory VDN extension, yielding a three-regime taxonomy. In the augmentative regime (Simple Spread), where the baseline is functional (74.4 %), EMA significantly improves success to 86.7 % (+12.3 pp, p<0.01) while naive dynamic updates collapse it to 15.2 %. In the essential regime (Level-Based Foraging), where the baseline is broken (0.1 %), any shaping unlocks the task (95.9 % under EMA). In the supplementary regime (SMAC 3m), where the baseline is near-saturated (98.8 %), stabilised shaping preserves performance (99.9 %) while unstabilised shaping adds variance without gain. These findings establish reward-signal stationarity as a necessary design constraint and indicate that regime placement is a practical predictor of whether dynamic LLM shaping helps or harms.
Faid Keddouri, Sohaib Houhou, Aissa Boulmerka +1
National School of Artificial Intelligence (ENSIA), Sidi Abdellah Campus, Algiers, Algeria · Cosys-Grettia, Univ Gustave Eiffel, F-77454 Marne-la-Vallee, France.