Agent-R1: Training Powerful LLM Agents with End-to-End Reinforcement Learning
Python
1,697
19 commits
updated Oct 12, 2026

Agent-R1 is a unified, modular framework for Agentic Reinforcement Learning. It trains multi-step LLM agents through a step-native RL loop, where the model observes an environment, generates an action, receives tool or environment feedback, and continues until the task is solved or terminated.
Unlike single-turn RL pipelines that treat interaction as one growing prompt-response sequence, Agent-R1 models every turn as a step-level MDP transition. This makes tool use, environment state, context management, reward assignment, and policy optimization explicit parts of the same training substrate.
opd branch.legacy branch.verl is moved to a git submodule and Agent-R1 extensions are separated from upstream code.Modern LLM infrastructure already has strong serving systems such as vLLM and SGLang, and strong distributed training systems such as DeepSpeed, FSDP, and Megatron-LM. Agentic RL needs to reconnect these two sides into a rollout -> reward -> replay -> update loop where the model interacts with tools and environments over multiple turns.
Agent-R1 is built around three design goals:
Token -> Text -> Token reconstruction.
In multi-turn agent training, the model is not just continuing a token sequence. Each model output can invoke tools, change the environment state, receive external feedback, and shape the next observation. Agent-R1 therefore treats the agent step as the basic interaction unit: a step records what the model saw, what action it produced, what feedback and reward the environment returned, and what observation should be exposed next. This step-level trajectory representation keeps rollout, replay, context construction, and credit assignment aligned with real agent decisions, while still allowing token-level policy losses inside each generated action.

Agent-R1 uses layered abstractions so new tasks can reuse the same trainer without rewriting the full RL stack.
| Layer | Responsibility | When to Use |
|---|---|---|
AgentFlowBase | Full control over prompt construction, model calls, branching, context management, and step assembly. | Complex custom agents that do not fit a standard environment loop. |
AgentEnvLoop | Generic loop connecting model generation with an environment's reset() / step() interface. | Agent tasks that can be modeled as environment interaction, including traditional RL-style environments. |
AgentEnv | Task environment interface returning observations, rewards, termination, and metadata. | Implementing the full environment logic for AgentEnvLoop. |
ToolEnv | Built-in environment for standard multi-turn tool calling. | Tool-augmented tasks where you only need to define tools. |
BaseTool | Standard interface for registering executable tools. | Adding calculators, search tools, APIs, or task-specific checkers. |
The main loop is:
prompt, agent_name, reward_model, and optional env_kwargs.AgentFlow and environment.done=True or max_steps is reached.Agent-R1 uses the same environment setup as verl, and the current version requires verl==0.7.0. You only need to clone this repository; there is no separate Agent-R1 installation step.
The recommended path is:
examples/gsm8k/run_steppo.sh as a sanity check that the environment is wired correctly.ToolEnv + BaseTool.Download the processed data with either the ModelScope CLI or git:
pip install modelscope
modelscope download --dataset Melmaphother/Agent-R1-data --local_dir data/agent-r1-data
git lfs install
git clone https://www.modelscope.cn/datasets/Melmaphother/Agent-R1-data.git data/agent-r1-data
Use the processed GSM8K files from the data release, or regenerate a minimal GSM8K dataset locally, then run the single-step script:
python3 -m recipes.gsm8k.data_preprocess.process_gsm8k --local_save_dir ~/data/gsm8k
bash examples/gsm8k/run_steppo.sh
This stage is only a setup check. It helps confirm that your environment, model path, dataset path, and training stack are wired correctly.
GSM8K + Tool is the simplest ToolEnv + BaseTool example. Use the processed GSM8K tool files from the data release, or regenerate the tool-augmented dataset locally, then launch the multi-step tool-calling script:
python3 -m recipes.gsm8k.data_preprocess.process_gsm8k_tool --local_save_dir ~/data/gsm8k_tool
bash examples/gsm8k/run_steppo_tool.sh
This path uses the generic AgentEnvLoop with the built-in ToolEnv and recipe-local calc_gsm8k_reward tool. The plain GSM8K script remains a single-turn environment sanity check.
Core concepts:
The Agent-R1 report evaluates Qwen3-4B across representative agent scenarios. The table below summarizes the main results; see Experiments for the experimental setting, task coverage, optimizer comparison, and context-management analysis.
| Method | GSM8K Acc. (%) | HotpotQA Acc. (%) | ALFWorld SR Seen (%) | ALFWorld SR Unseen (%) | WebShop Score (%) | WebShop SR (%) |
|---|---|---|---|---|---|---|
| ReAct | 53.1 | 25.8 | 7.14 | 2.98 | 51.58 | 23.8 |
| GRPO | 83.3 | 59.4 | 81.29 | 74.58 | 65.83 | 44.2 |
| PPO | 78.1 | 56.7 | 76.42 | 72.38 | 70.18 | 46.0 |
| REINFORCE | 78.9 | 52.8 | 73.84 | 69.57 | 63.41 | 41.8 |
| RLOO | 81.6 | 55.2 | 79.08 | 73.46 | 68.02 | 45.1 |
For a new task, keep the trainer intact and implement the task-specific layers:
recipes/<task>/
base.yaml
data_preprocess/process_<task>.py
<task>_agent_flow.py
reward_fn.py
prompts.py
utils.py
env/ # optional environment service or wrappers
Typical migration checklist:
prompt, reward_model, agent_name, and env_kwargs.main contains the current v0.1.0 architecture based on Step-level MDP and layered abstractions.legacy preserves the previous implementation for reference.verl that includes the AgentFlow / async rollout stack required by this repository.This work is conducted at the State Key Laboratory of Cognitive Intelligence, USTC. We gratefully acknowledge the ideas and infrastructure from DeepSeek-R1, veRL, and RAGEN. We also thank Prof. Qi Liu and Prof. Mingyue Cheng for their guidance and support.
If you find Agent-R1 useful in your research, please cite:
@misc{cheng2026agentr1unifiedmodularframework,
title={Agent-R1: A Unified and Modular Framework for Agentic Reinforcement Learning},
author={Mingyue Cheng and Shuo Yu and Daoyu Wang and Qingchuan Li and Xiaoyu Tao and Jie Ouyang and Yucong Luo and Yitong Zhou and Qi Liu and Enhong Chen},
year={2026},
eprint={2511.14460},
archivePrefix={arXiv},
primaryClass={cs.CL},
url={https://arxiv.org/abs/2511.14460},
}
(top 24 of 30)
2,396 followers · starred Apr 2025
10,533 followers · starred Oct 2025
4,415 followers · starred Nov 2025
400 followers · starred Mar 2025
Agent-R1: Training Powerful LLM Agents with End-to-End Reinforcement Learning
Python
1,697
19 commits
updated Oct 12, 2026

Agent-R1 is a unified, modular framework for Agentic Reinforcement Learning. It trains multi-step LLM agents through a step-native RL loop, where the model observes an environment, generates an action, receives tool or environment feedback, and continues until the task is solved or terminated.
Unlike single-turn RL pipelines that treat interaction as one growing prompt-response sequence, Agent-R1 models every turn as a step-level MDP transition. This makes tool use, environment state, context management, reward assignment, and policy optimization explicit parts of the same training substrate.
opd branch.legacy branch.verl is moved to a git submodule and Agent-R1 extensions are separated from upstream code.Modern LLM infrastructure already has strong serving systems such as vLLM and SGLang, and strong distributed training systems such as DeepSpeed, FSDP, and Megatron-LM. Agentic RL needs to reconnect these two sides into a rollout -> reward -> replay -> update loop where the model interacts with tools and environments over multiple turns.
Agent-R1 is built around three design goals:
Token -> Text -> Token reconstruction.
In multi-turn agent training, the model is not just continuing a token sequence. Each model output can invoke tools, change the environment state, receive external feedback, and shape the next observation. Agent-R1 therefore treats the agent step as the basic interaction unit: a step records what the model saw, what action it produced, what feedback and reward the environment returned, and what observation should be exposed next. This step-level trajectory representation keeps rollout, replay, context construction, and credit assignment aligned with real agent decisions, while still allowing token-level policy losses inside each generated action.

Agent-R1 uses layered abstractions so new tasks can reuse the same trainer without rewriting the full RL stack.
| Layer | Responsibility | When to Use |
|---|---|---|
AgentFlowBase | Full control over prompt construction, model calls, branching, context management, and step assembly. | Complex custom agents that do not fit a standard environment loop. |
AgentEnvLoop | Generic loop connecting model generation with an environment's reset() / step() interface. | Agent tasks that can be modeled as environment interaction, including traditional RL-style environments. |
AgentEnv | Task environment interface returning observations, rewards, termination, and metadata. | Implementing the full environment logic for AgentEnvLoop. |
ToolEnv | Built-in environment for standard multi-turn tool calling. | Tool-augmented tasks where you only need to define tools. |
BaseTool | Standard interface for registering executable tools. | Adding calculators, search tools, APIs, or task-specific checkers. |
The main loop is:
prompt, agent_name, reward_model, and optional env_kwargs.AgentFlow and environment.done=True or max_steps is reached.Agent-R1 uses the same environment setup as verl, and the current version requires verl==0.7.0. You only need to clone this repository; there is no separate Agent-R1 installation step.
The recommended path is:
examples/gsm8k/run_steppo.sh as a sanity check that the environment is wired correctly.ToolEnv + BaseTool.Download the processed data with either the ModelScope CLI or git:
pip install modelscope
modelscope download --dataset Melmaphother/Agent-R1-data --local_dir data/agent-r1-data
git lfs install
git clone https://www.modelscope.cn/datasets/Melmaphother/Agent-R1-data.git data/agent-r1-data
Use the processed GSM8K files from the data release, or regenerate a minimal GSM8K dataset locally, then run the single-step script:
python3 -m recipes.gsm8k.data_preprocess.process_gsm8k --local_save_dir ~/data/gsm8k
bash examples/gsm8k/run_steppo.sh
This stage is only a setup check. It helps confirm that your environment, model path, dataset path, and training stack are wired correctly.
GSM8K + Tool is the simplest ToolEnv + BaseTool example. Use the processed GSM8K tool files from the data release, or regenerate the tool-augmented dataset locally, then launch the multi-step tool-calling script:
python3 -m recipes.gsm8k.data_preprocess.process_gsm8k_tool --local_save_dir ~/data/gsm8k_tool
bash examples/gsm8k/run_steppo_tool.sh
This path uses the generic AgentEnvLoop with the built-in ToolEnv and recipe-local calc_gsm8k_reward tool. The plain GSM8K script remains a single-turn environment sanity check.
Core concepts:
The Agent-R1 report evaluates Qwen3-4B across representative agent scenarios. The table below summarizes the main results; see Experiments for the experimental setting, task coverage, optimizer comparison, and context-management analysis.
| Method | GSM8K Acc. (%) | HotpotQA Acc. (%) | ALFWorld SR Seen (%) | ALFWorld SR Unseen (%) | WebShop Score (%) | WebShop SR (%) |
|---|---|---|---|---|---|---|
| ReAct | 53.1 | 25.8 | 7.14 | 2.98 | 51.58 | 23.8 |
| GRPO | 83.3 | 59.4 | 81.29 | 74.58 | 65.83 | 44.2 |
| PPO | 78.1 | 56.7 | 76.42 | 72.38 | 70.18 | 46.0 |
| REINFORCE | 78.9 | 52.8 | 73.84 | 69.57 | 63.41 | 41.8 |
| RLOO | 81.6 | 55.2 | 79.08 | 73.46 | 68.02 | 45.1 |
For a new task, keep the trainer intact and implement the task-specific layers:
recipes/<task>/
base.yaml
data_preprocess/process_<task>.py
<task>_agent_flow.py
reward_fn.py
prompts.py
utils.py
env/ # optional environment service or wrappers
Typical migration checklist:
prompt, reward_model, agent_name, and env_kwargs.main contains the current v0.1.0 architecture based on Step-level MDP and layered abstractions.legacy preserves the previous implementation for reference.verl that includes the AgentFlow / async rollout stack required by this repository.This work is conducted at the State Key Laboratory of Cognitive Intelligence, USTC. We gratefully acknowledge the ideas and infrastructure from DeepSeek-R1, veRL, and RAGEN. We also thank Prof. Qi Liu and Prof. Mingyue Cheng for their guidance and support.
If you find Agent-R1 useful in your research, please cite:
@misc{cheng2026agentr1unifiedmodularframework,
title={Agent-R1: A Unified and Modular Framework for Agentic Reinforcement Learning},
author={Mingyue Cheng and Shuo Yu and Daoyu Wang and Qingchuan Li and Xiaoyu Tao and Jie Ouyang and Yucong Luo and Yitong Zhou and Qi Liu and Enhong Chen},
year={2026},
eprint={2511.14460},
archivePrefix={arXiv},
primaryClass={cs.CL},
url={https://arxiv.org/abs/2511.14460},
}
(top 24 of 30)
2,396 followers · starred Apr 2025
10,533 followers · starred Oct 2025
4,415 followers · starred Nov 2025
400 followers · starred Mar 2025