GoogleWei WeiTutorial
Multi-Turn Agentic Reinforcement Learning with Tunix and Gemma 4 on Google TPUs
Summary
Training real-world AI agents requires reasoning over multiple turns with tool use and environment feedback in a multi-step loop. This post presents a method to train a multi-turn tool-using LLM agent on Cloud TPU v6e-8 using Tunix’s agentic reinforcement learning pipeline. The agent plays the Plane Strike board game on a 6x6 grid with a hidden eight-cell plane in one of four orientations, using Gemma 4 E2B in thinking mode. The pipeline includes a custom environment, Gemma 4 native tool calling via tool declarations and in-turn tool responses, a conversation agent for observation-to-message translation, and GRPO with multi-turn rollouts using vllm-tpu and prefix caching. After 100 training steps, the win rate on held-out boards jumps from 9.4% to 95% while average game length drops from 22.44 to about 16 strikes.
Context
Multi-turn agentic RL for tool-using LLMs is complex due to variable-length rollouts and credit assignment. The post addresses this by using Tunix’s agentic RL pipeline on TPUs.
Approach / What changed
Implement a multi-turn RL pipeline in Tunix with four components: TaskEnvironment (PlaneStrikeEnv), Tool and Chat Template Parser (StrikeTool and Gemma4ToolChatTemplateParser), ConversationAgent (PlaneStrikeAgent), and TrajectoryCollection with GRPOLearner, using vllm-tpu and prefix caching for efficient rollouts on Cloud TPU v6e-8.
Takeaways
After 100 steps of agentic GRPO, the Gemma 4 E2B agent’s win rate on Plane Strike increases from 9.4% to 95% while average game length decreases from 22.44 to about 16 strikes.
The training uses GRPO with loss_algo=‘gspo-token’ and advantage_estimator=‘rloo’ and exact_token_continuity=True to preserve token IDs across multi-turn rollouts.
Setting rollout_vllm_server_mode to true and enable_prefix_caching to true enables continuous asynchronous multi-turn rollouts, addressing the variable-length bottleneck.
FAQ
How does the agent handle multi-turn tool calling?
After each tool call, the model pauses at the native stop token like <tool_response> and waits for the environment response; then the model continues generating its next thought and tool call within the same assistant turn.
What config settings are important for multi-turn rollouts?
Set rollout_vllm_server_mode to true for continuous asynchronous rollouts and enable_prefix_caching to true to cache growing conversation history. Also use exact_token_continuity=True to avoid retokenization drift across turns.
What initial win rate does the base model achieve and how much does training improve it?
The base Gemma 4 E2B model wins only 9.4% of games with about 22.44 strikes average. After 100 training steps, win rate reaches 95% and average game length drops to about 16 strikes.
Source and freshness
- Source
- developers.googleblog.com
- Published
- Added to Yomu
Summaries are generated from the original by a language model. Check the original before relying on it.
Keep reading
Related reading
The Good Stuff
Paid picks we use ourselves. Links carry a referral code — a subscription through one earns us a commission at no extra cost to you.
The best engineering reads, once a week
One useful email. Unsubscribe anytime.