mll-lab-nu/RAGEN

Agent RL framework for LLM agents: multi-turn reinforcement learning with StarPO and reasoning-collapse diagnostics

RAGEN: Training Agents by Reinforcing Reasoning

What it is

RAGEN (short for Reasoning AGENT) is a flexible reinforcement learning (RL) framework for training reasoning LLM agents — AI models that think step-by-step and take actions in an environment over multiple turns. It's built around a custom algorithm called StarPO and comes with tools to diagnose why agent training sometimes fails.

The core algorithm: StarPO

StarPO stands for State-Thinking-Actions-Reward Policy Optimization. It's a unified RL framework for training multi-turn, trajectory-level agents. The idea:

  • Rollout stage: The LLM generates multiple trajectories. At each step, it produces a reasoning-guided action in the format thinking... response<ans> action </ans>. The environment responds with a reward and the next state.
  • Update stage: The model optimizes entire trajectories using importance sampling. Two supported methods:
    • PPO — token-level advantage estimation via a value function over trajectories.
    • GRPO — normalized reward assigned to the full trajectory.

Agent-environment interactions are modeled as Markov Decision Processes (MDPs) where states and actions are token sequences, letting the LLM reason over environment dynamics.

What problems it solves

RAGEN focuses on diagnosing hidden failure modes in agentic reinforcement learning. Two specific ones:

  • Echo Trap — a failure mode identified in RAGEN V1.
  • Reasoning collapse — introduced in RAGEN-2. This is when the model's reasoning becomes template-like: it looks diverse for a single input but is actually identical across different inputs. The README notes that entropy alone can't detect this.

RAGEN-2 decomposes reasoning quality into two axes:

  • Within-input diversity — Conditional Entropy H(Z|X)
  • Cross-input distinguishability — Mutual Information I(X;Z)

This yields four reasoning regimes: diverse reasoning, template collapse, compressed reasoning, and low-entropy collapse.

Key features

  • 10 built-in environments: Sokoban, FrozenLake, WebShop, DeepCoder, SearchQA, Lean, Bandit, Countdown, MetaMathQA, Sudoku.
  • Gym-compatible interface — easy to add custom environments.
  • Flexible control over reasoning processes, reward assignment, and prompt-rollout structures.
  • SNR-Adaptive Filtering (V2): a lightweight rollout-filtering method based on reward variance to reduce noisy gradient updates. The README claims it consistently improves training across algorithms, model scales, and modalities.

How to use it

git clone https://github.com/mll-lab-nu/RAGEN.git
cd RAGEN
conda create -n ragen python=3.12 -y && conda activate ragen
bash scripts/setup_ragen.sh

Train (default, no filter):

python train.py --config-name _2_sokoban

Train with SNR-Adaptive Filtering (Top-p):

python train.py --config-name _2_sokoban \
  actor_rollout_ref.rollout_filter_strategy=top_p \
  actor_rollout_ref.rollout.rollout_filter_value=0.9

Evaluate:

python -m ragen.llm_agent.agent_proxy --config-name _2_sokoban

Related projects

The README lists several projects powered by or inspired by RAGEN, including BAGEN (budget-aware agents), VAGEN (visual agents), ROLL (scaling library for RL with LLMs), Search-R1 (search-engine-calling agents), and Agent-R1 (end-to-end RL agents).

Papers

  • RAGEN V1: "RAGEN: Understanding Self-Evolution in LLM Agents via Multi-Turn Reinforcement Learning" (arXiv 2504.20073)
  • RAGEN-2: "RAGEN-2: Reasoning Collapse in Agentic RL" (arXiv 2604.06268)

Status

RAGEN V1 was released January 2025; RAGEN-2 was released March 2026. The project is actively developed, with planned features including an async rollout engine, HTTP-based environment interface, multi-modal agent support, and a public leaderboard.

Related

  • Project
  • Project
  • Project
  • Project
  • Project