About Agentic RL Lab
Agentic RL Lab is an open repository of experiment notes and tutorials.
I use PyTRIO to reproduce and study LLM and agent reinforcement learning methods, bringing together the algorithms, runnable code, training process and evaluation. Each note should give you something concrete to change, run and check for yourself.
What is Agentic RL
Agentic RL trains a model to complete a task, not just to produce an answer. The LLM is the policy; the environment is a stateful external system such as a search engine, a Python interpreter or a text game. At each turn, the model reads its current context and generates text or a tool call as its action. The environment executes the action, updates its own state, and returns the result as an observation. This repeats until the task ends.
A trajectory therefore looks like this:
prompt → action_1 → observation_1 → action_2 → ... → action_T → rewardThat trajectory is one rollout. The model sees the prompt, its own previous actions, and the observations returned by the environment; it cannot see the environment's internal state and can only probe it through actions. What it can observe next depends on what it just did: the trajectory is shaped by both the policy and the environment — in RL terms, a partially observable decision process (POMDP).
For training, the whole trajectory is concatenated into one token sequence. As in single-turn RLVR, the prompt does not contribute to the loss; in addition, observations returned by the environment are given input and must be masked too. Only the action tokens generated by the model (reasoning, tool calls and the final answer) contribute to the loss. Rewards usually appear only at the end of the trajectory, and GRPO, PPO and related algorithms turn them into advantages that are propagated back.
Agentic RL shares the same losses and advantages as single-turn RLVR (GRPO on GSM8K, for example); the difference is in the trajectory:
| Single-turn RLVR | Agentic RL | |
|---|---|---|
| State | The prompt plus generated tokens | Plus environment state the model cannot see and can only probe through tools |
| One rollout | One generation | Several generations interleaved with tool calls |
| Tokens in the loss | All tokens generated by the model (prompt masked) | Only the model's action tokens (prompt and observations masked) |
| Reward | Whether the answer is right | Whether the task succeeds, usually sparser and delayed |
Longer trajectories bring three additional training problems:
- Credit assignment: the reward arrives at the end, and a group-relative advantage cannot by itself identify which intermediate step mattered. TEMPO cuts long trajectories into segments and trains a generative critic to value them at segment ends; AgentOPSD has a teacher re-read the whole trajectory and supervise each turn.
- Context is the state: environment state does not enter the model on its own; observations carry it into the context. How much history to keep and when to truncate directly changes what the model can learn.
- Sampling cost: every action may call an external service, so a rollout is slower than single-turn sampling and more likely to fail.
The multi-turn chapters in this lab start from different environments: Search-R1 connects a search engine, ReTool executes code, ALFWorld plays a text game, and Spec-o3 puts images and tool outputs in the same trajectory. The single-turn chapters GRPO, DAPO and GSPO connect sampling, rewards, advantages and policy updates into a complete training loop, while OPD and OPSD turn teacher feedback into the learning signal. For the academic definition and taxonomy, see the survey The Landscape of Agentic Reinforcement Learning for LLMs: A Survey.
Author and sources
This lab is maintained by KMnO4-zx. Notes link to their papers, implementation and public experiment records so that readers can trace the evidence behind a conclusion. The Chinese and English editions share the same experiment code and original figures. Original code comments, logs and text inside figures may remain in Chinese. Report translation or reproduction issues through GitHub Issues or the edit link on each page.
Content Contributors
- MRLE (Beijing Jiaotong University): Tournament-GRPO
What an experiment note contains
Between a paper and a working experiment lie many practical details: how sampling is organized, how rewards are computed, which tokens receive updates, and how evaluation differs from training.
The notes follow these questions through three stages:
- Paper and intuition: the problem, the method and its core variables.
- Code and training: how data, rewards, losses and the training loop fit together.
- Results and limitations: what was observed, and where the implementation differs from the original method.
Each chapter records its own models, data and configuration. Scores from different chapters are not directly comparable. Algorithm-level reproductions also make different simplifications; read each note’s limitations alongside its results.
Why PyTRIO?
I wanted to study Agentic RL in depth, but limited GPU access and the complexity of training and inference infrastructure kept getting in the way. PyTRIO lets a remote service handle model training and sampling while I keep the experiment loop local and easier to inspect and change.
Experiments use SwanLab for tracking. Relevant public records and paper references appear in the individual notes so readers can compare the implementation with the observations.
Where to start
- New to the topic? Read the learning path, then complete environment setup.
- Already familiar with training? Choose a research direction in the experiment handbook.
- Ready to run code? Open a chapter’s quick start and follow its dependencies and commands.
Improve the experiments together
Use GitHub Issues to share reproduction notes, report problems or propose experiments. Include the model name, command, dependency versions and relevant logs to make a report easier to investigate.
See the GitHub repository for source code and license information. The WeChat community entry is in this issue.