fix(#2995): ignore leading vis-thinking block in react parser#2996
Merged
Conversation
Collaborator
|
I am very appreciate your contribution. we will test and merge it soon. |
15 tasks
chenliang15405
approved these changes
Mar 22, 2026
chenliang15405
left a comment
Collaborator
There was a problem hiding this comment.
Thanks for your contribution. LGTM
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Description
更新了react_parser.py,让 ReAct 解析在提取 Thought / Phase / Action / Action Input 之前,先忽略前置的 vis-thinking 包装内容。
这次改动只发生在 parser 层,范围很小:
当模型输出以前置 VisThinking 块开头时,parser 会先剥离这段 thinking 包装,再继续解析正文。
如果剥离之后没有正文内容,parser 会返回空步骤列表,而不是把 thinking 内容误当成可执行的 ReAct step。
thinking 结束位置的判断也做了收敛,避免两类边界问题:
不会因为 thinking 内部出现 fence 而过早截断
不会把后续真实正文错误吞进 thinking 区域
这个修改修复了 deepseek-reasoner 在 ReAct 场景下,因 reasoning 内容被误解析成多个 step,从而触发 Only one action is allowed each time. 的问题。
How Has This Been Tested?
测试覆盖的场景包括:
标准 ReAct 文本解析行为保持不变
前置 vis-thinking 块会被正确忽略
只有 vis-thinking、没有正文时,返回空步骤
thinking 内容内部包含 standalone fence 时,仍能正确跳过 thinking
正文本身包含 standalone fence 时,不会被错误吞掉,仍能正常解析
Snapshots:
Include snapshots for easier review.
Checklist: