Repository navigation
fix: 伪工具调用救回机制全面加固(误执行 0 / 漏检 0) - #853
Open
zhangPinkdolphin wants to merge 3 commits into
Open
zhangPinkdolphin wants to merge 3 commits into
zhangPinkdolphin wants to merge 3 commits into
Conversation
- llmcore: 解析层将正文标记式调用(标签体/属性式/自闭合/invoke+parameter/DSML变体)转为真调用; 仅处理summary之后, 跳过代码围栏示例 - llmcore: find_phantom_tool_markup 检测无法挽救的残缺标记(仅尖括号标签形态, 尾部600字符窗口, 排除代码span) - ga: do_no_tool 检测到伪标记时强提示重试, 成功后重置计数
上一版(lsdefine#853)只覆盖 <code_run> 家族且以"检测到即重试"为主, 实际运行中仍有两类问题:①反引号/围栏里被讲解的标签会被误判执行; ②<ask_user><question>..</question></ask_user> 这类裸子标签形态、以及 "调用后跟一段说明"的形态仍被漏检。 本次改为解析优先 + 全文级检测: llmcore.py - _strip_dsml_tags:容错 | | ‖ 单/双/三分隔符与破碎开闭标签 - DsmlStreamFilter:流式跨 chunk 剥离(chat_completions / responses 两条路径) - _code_candidates/_xml_code_calls:属性式、体内参数式、压平单行式、JSON 体 - _bare_tag_calls/_bare_child_args:工具名+裸子标签参数;参数体必须纯净标签对, 正文 HTML 片段与裸脚本不会被误判 - _looks_like_prose:中文散文判为"被讨论的标签"→否决 - _try_parse_tool_args:arguments 侧同样剥标记(上游 lsdefine#846-B) - leaked_markup_kind/incomplete + salvaged_call_problem:可完整解析才执行, 截断/语法错/空参数一律转重试 ga.py - 尾部 50 字检测改为全文级:能解析就救回执行,残缺则不执行并要求重生成 实测:36 项验收用例全绿;50 条真实泄漏日志逐块对拍改前/改后行为完全一致(零退步); 对照 lsdefine#838 修复其两处误执行与两处漏检。
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.
现象
模型偶尔不通过结构化
tool_calls,而是把工具调用写进正文:当前 main 对这类回复既不解析也不告警:该轮
tool_calls为空,模型以为已执行,agent 空转/丢步,只能翻日志发现——静默失败。方案:解析优先,全文级检测
本 PR 取代上一版(只认
<code_run>家族 + 检测到即重试)的做法,改为能完整解析就直接执行,残缺才重试,避免白白浪费一轮。llmcore.py
_strip_dsml_tags||‖单/双/三分隔符、破碎开闭标签、dsml_下划线式DsmlStreamFilterchat_completions与responses两条路径都接_code_candidates/_xml_code_calls_bare_tag_calls/_bare_child_args_looks_like_prose_try_parse_tool_argsarguments字符串侧同样剥标记(#846-B 形态)salvaged_call_problemga.py
尾部 50 字检测 → 全文级检测;救回的调用经
dispatch直接执行并把结果回流给模型;残缺则不执行、要求重生成。frontends/tests/test_dsml_tool_markup.py
36 项验收用例,分 5 组:
<不受影响、坏 JSON 退回_raw不抛)→ 3/3验证
对照同期两个 PR:
ask_user风险与边界
ga.py用do_*动态推导),新增工具若命名不规范需同步