TL;DR
When training LLM agents via reinforcement learning, judging an entire multi-step attempt solely by whether it succeeded at the very end penalizes smart early moves in failed runs and rewards clumsy detours in successful ones. RewardFlow solves this by weaving separate attempts at the same task into a shared map—a state graph—and letting reward "flow" backward from winning endpoints. Without needing expensive human labels or separate judge models, agents learn exactly which individual actions move the needle.
What Problem Does This Paper Address?
Imagine an AI shopping assistant tasked with buying a specific pair of running shoes. It navigates the search bar brilliantly, filters by size, finds the exact shoe—and then clicks "Cancel" instead of "Buy." In standard reinforcement learning (RL), the agent gets a big fat zero at the end of this trajectory (sequence of actions). Because the final outcome failed, standard algorithms like GRPO treat every step along the way as a mistake, discouraging the brilliant search skills right alongside the fatal final click. Conversely, if an agent wanders aimlessly through twenty wrong menus before accidentally stumbling onto the "Buy" button, every detour gets reinforced.
This is the classic credit-assignment problem: figuring out which specific actions deserve praise or blame when feedback only arrives at the finish line.
Existing workarounds have headaches of their own. Training a separate Process Reward Model (PRM) to grade every step requires heavy compute and is notorious for "reward hacking" (where the agent learns to trick the grader rather than solve the task). Meanwhile, methods like GiGPO compare actions across attempts, but still judge each action only by how its own trajectory ended. The authors ask: What if we pool all the agent's attempts together to map out the environment, and deduce step-by-step rewards purely from the geometry of that map?
Methods
RewardFlow builds on standard group-based RL (where an agent tries the same task $G$ times per training step), introducing a clever graph-based middle layer before updating the model via a standard clipped PPO objective.
Here is how the pipeline works:
- Stitching Trajectories into a State Graph: Across multiple attempts at a task, agents frequently visit the exact same situations—like standing at the same desk or viewing the same product page. RewardFlow groups equivalent (or semantically similar, via text embeddings) states into single nodes and connects them using the valid actions the agent took. Suddenly, isolated attempts merge into a directed graph. If Trajectory A finds the right shoe and fails, while Trajectory B stumbles onto that same shoe page and buys it, the graph links Trajectory A's smart search directly to Trajectory B's victory.
- Propagating State Potentials: Any terminal state where the task succeeded gets a value (or potential) of $1$. Using a fast reverse breadth-first search (BFS), this signal propagates backward through the graph, decaying by a factor $\gamma \in (0,1)$ with each hop along the shortest path to success. Closer to victory means higher potential.
- Action Rewards as Potential Differences: Every valid action's reward is simply the potential of the state it lands in minus the potential of the state it left ($\tilde{r}_t = \phi_{t+1} - \phi_t$). Actions that step closer to success get positive rewards; detours that step away get penalized.
- Complementary Advantages: RewardFlow normalizes these action rewards among all actions taken from the same node to get an action-level advantage, and adds it to the standard trajectory-level advantage (from final pass/fail outcomes).
Datasets
The authors evaluate existing benchmarks spanning four distinct domains (no new datasets are introduced):
- ALFWorld: Text-based household tasks (including an out-of-distribution split featuring unseen room layouts).
- WebShop: Simulated online shopping requiring search and option selection.
- Sokoban: Visual grid-world box-pushing puzzles (evaluating vision-language models).
- Retrieval-based Search QA: Trained on NQ and HotpotQA, and tested both in-distribution and out-of-distribution on TriviaQA, PopQA, 2Wiki, Musique, and Bamboogle.
Key Insights and Ideas
- Cross-trajectory rescue: Because paths merge at shared states, a good action trapped inside a failed attempt is "rescued" if any other attempt figures out how to win from that shared state onward.
- Shortest-path beats averaging: When propagating rewards backward through the graph, taking the shortest path (via BFS) dramatically outperforms averaging paths or using Personalized PageRank—especially in puzzles like Sokoban (49.5% success vs. 33.6% for mean aggregation), where one optimal route matters far more than five clumsy loops.
- Micro and macro signals need each other: Using only graph-derived action advantages tanks performance on ALFWorld (7.0% success), while trajectory outcomes alone hit 59.4%. Combining them jumps to 75.5%—local step guidance keeps the agent on track, while global outcome supervision ensures it actually crosses the finish line.
- Skipping external PRMs works better: Off-the-shelf 7B–8B Process Reward Models actually hurt GRPO training on ALFWorld due to out-of-distribution scoring errors, whereas RewardFlow's parameter-free graph math boosts it significantly.
Key Results
Across Qwen2.5 (1.5B, 3B, 7B) and Qwen2.5-VL (3B, 7B) models, RewardFlow consistently outperforms RLOO, GRPO, and GiGPO.
- Big leaps on puzzles and tasks: Averaged across model scales, RewardFlow beats GiGPO by 6.2% absolute success rate on ALFWorld and WebShop combined, and by a massive 29.7% on visual Sokoban (e.g., jumping from 37.8% to 67.4% at 7B).
- Search & Generalization: On search benchmarks, it improves average accuracy over GiGPO by 2.2% (3B) and 1.9% (7B), despite relying on approximate cosine-similarity matching to group varied search passages. On unseen ALFWorld rooms at 1.5B, it hits 66.1% success compared to GiGPO's 46.9%.
- Virtually free compute: Because graph building and reverse BFS run on CPU without extra neural network calls, RewardFlow adds just 1.47 to 2.39 seconds per training step on 3B models—a tiny fraction of the ~200+ seconds spent sampling and updating weights.
Limitations and Future Work
- All-failure groups yield no signal: Because potentials are anchored strictly to observed successes, if all $G$ sampled trajectories in a batch fail, every potential is zero and no learning signal is generated for that step.
- Defining "shared states" in open-ended worlds: In structured games or web pages, matching identical states is straightforward. In open-ended tasks like search or math reasoning, observations rarely match word-for-word, requiring semantic embeddings and similarity thresholds. While preliminary math-reasoning tests look promising, developing more reliable ways to group states across free-form reasoning paths remains a key target for future work.
Summary updated