Module 3 · Reinforcement learning for agents · Lesson 7
Multi-turn RL environments
How to turn an agent's tools into a reinforcement learning environment: what the trainer runs per rollout, which tokens the policy is trained on, how one final reward is shared across several tool-calling turns, what a run costs, and how to choose a framework or hosted trainer.
By the end of this lesson you can
- Wrap an agent's tools and stubs as an RL environment with a reset hook, tool methods and a trajectory reward, using TRL's environment_factory
- Explain why tool-result tokens are masked from the loss, and compute the share of a rollout's tokens the policy is actually trained on
- Compute episode-level and step-level (anchor-state) advantages for a group of multi-turn rollouts, and say what each one blames
- Estimate the token and dollar cost of a multi-turn RL run on a free GPU, a rented GPU and a per-token hosted trainer
- Choose between TRL, verifiers, OpenEnv, ART, SkyRL and Agent Lightning for a given agent stack