[rollout] agent loop should delegate think stripping to inference engine's native reasoning parser
Summary
Add reasoning parser support to the agent loop's post-generation pipeline, so think-block content is excluded before tool parsing, aligning training-time behavior with inference-time chat completion processing.
Motivation
The verl agent loop, constrained by token-in-token-out, decomposes LLM interaction into: apply chat template → generate() → decode → tool parser. This pipeline is missing the reasoning parser that inference engines (vLLM/SGLang) normally apply between decode and tool parsing when serving chat completions.
Without reasoning parsing, tool call patterns inside <think>...</think> blocks are treated as real tool calls and executed during training. This:
- Produces spurious tool results that pollute the conversation history (see #4757).
- Teaches the model that loose tool call placement (within think blocks) is acceptable.
- Causes benchmark regression when evaluation harnesses apply stricter tool call parsing (see #6223, #6252).
Proposed solution
Insert a reasoning parser step between decode and tool parsing in the agent loop, reusing the inference backend's own parser through a thin adaptation layer rather than reimplementing per-model logic:
generate() → decode → reasoning parser (strip think) → tool parser → execute tools
This keeps the training path aligned with the inference path, avoids model-specific parser duplication, and improves compatibility across model families.
Thank you for this feature request with clear motivation.
Assessment:
The reasoning parser integration is a legitimate gap between training and inference paths. During inference, vLLM/SGLang apply think-stripping before tool parsing, but the verl agent loop currently does not. This causes:
- Spurious tool execution from think-block content during training
- Model trained to accept loose tool call placement
- Benchmark regression when eval harnesses use stricter parsing
Proposed implementation:
The approach of delegating to the inference engine's native parser is correct — reimplementing per-model logic would be brittle and hard to maintain.
A thin adaptation layer between generate() and tool parser would:
- Detect think-block delimiters (e.g.,
<think>...</think>) - Extract content between delimiters
- Pass extracted tool calls to the tool parser
- Preserve think content in conversation history for downstream processing
Considerations:
- Different models may use different delimiters (e.g.,
<think>,<reasoning>,<reflection>). The adaptation layer should be model-agnostic and configurable. - The think content should still be preserved in the conversation — only the tool call extraction is delegated.
- This aligns with how vLLM chat completion handles reasoning models.
Would you like to open a PR for this? I can help review the design.
感谢您提出这个动机明确的功能请求。
评估:
推理解析器集成是训练和推理路径之间的一个合理缺口。在推理期间,vLLM/SGLang在工具解析前会应用think-stripping,但verl agent loop目前没有。这导致:
- 训练期间think块内容产生虚假工具执行
- 模型被训练为接受松散的工具调用放置
- 当评估框架使用更严格的解析时出现基准回归
拟议实现:
委托给推理引擎原生解析器的方法是正确的——重新实现每个模型的逻辑会脆弱且难维护。
在 generate() 和工具解析器之间的薄适配层将:
- 检测think块分隔符(如
<think>...</think>) - 提取分隔符之间的内容
- 将提取的工具调用传递给工具解析器
- 在对话历史中保留think内容供下游处理
考虑因素:
- 不同模型可能使用不同的分隔符(如
<think>、<reasoning>、<reflection>)。适配层应该是模型无关的和可配置的。 - think内容仍应保留在对话中——只有工具调用提取被委托。
- 这与vLLM聊天完成处理推理模型的方式一致。
您是否有兴趣提交PR?我可以帮助审查设计。
🤖 This response was generated by an AI assistant (OpenClaw + Minimax 2.7). If you have follow-up questions, please feel free to discuss!