amazon.scienceFrederick RobinsonAnnouncement
Capturing token IDs during agentic interactions for better reinforcement learning
Summary
Reinforcement learning for agentic tasks requires updating model parameters against the precise token sequences generated during rollouts. Standard agent harnesses frequently modify conversation transcripts through message compaction and tool formatting, causing retokenization drift that degrades policy-gradient training. Turnstile addresses this issue as a Rust-based proxy situated between agent harnesses and inference backends such as SGLang. By intercepting OpenAI-compatible Chat Completions traffic, the proxy records exact token IDs, log probabilities, loss masks, weight versions, and mixture-of-experts routing traces at the moment of generation. Validation across text-based coding and multimodal computer-use agents demonstrated steady reinforcement learning improvements without requiring modifications to agent harnesses.
Context
Reinforcement learning for agentic workflows requires training on the exact context that the behavior policy observed. Agent harnesses frequently rewrite, compact, or reformat prompt text, causing retokenization drift and chat template drift where reconstructed text produces different token sequences than those originally sampled. Additionally, harnesses cannot directly observe backend-specific state such as mixture-of-experts routing traces or processed visual tensors, leading to degraded training signals.
Approach / What changed
Turnstile was developed as a Rust proxy positioned between agent harnesses and inference backends like SGLang. Operating via standard OpenAI Chat Completions endpoints without requiring changes to existing harnesses, it captures token IDs, log probabilities, loss masks, and weight-version boundaries at the moment of generation. The proxy also tracks mixture-of-experts routing decisions, splitting trajectories on prefix mismatches, and stores raw and processed visual tensors to construct framework-agnostic training trajectories.
Takeaways
Text-based transcripts from agent harnesses often suffer from retokenization and chat template drift, generating token sequences that diverge from what the model actually processed.
Capturing rollout state at the proxy layer preserves exact token IDs, per-token log probabilities, and loss masks without requiring modifications to existing agent harnesses.
Turnstile records mixture-of-experts routing traces to split mismatched trajectories and stores processed image features directly to maintain consistency in multimodal RL training.
Source and freshness
- Source
- amazon.science
- Published
- Added to Yomu
- Last updated
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.