Repository navigation
fix(tools): 「阻止了无效的工具调用」误拦根因修复——嗅探器 rawArgs 契约 + 必填字段别名纠错 - #395
Merged
Merged
Conversation
用户报告文件类工具频繁被拦 Blocked invalid tool call。两个根因:
1. ContentToolCallSniffer.argsOf 在 arguments 串解析失败时静默替换 {}
且不带原始串——GH#113 类网关(工具调用经 content 流下发)上每次
调用都被必填字段预检拦成「无效工具调用」。补齐 GH#61/#83/#146 契约:
解析失败携带 rawArgs,预检可尝试截断修复或给出精确的「参数流不完整」
拒绝,替代无上下文的笼统拦截。
2. ToolJsonRepair 字段纠错只覆盖编辑距离 1(comand→command 这类拼写
错),模型训练习惯名 file_path→path(距离 6)救不回来——完整合法
的载荷被必填校验判死。新增策略 4:枚举别名表(path/command/content/
pattern/query/url/code/action/name/title/question 的常见变体),
仅在必填字段缺失且变体键不是本工具 schema 字段时改名。
验证:全量 6662 测试 0 失败(新增 6 用例锁定两契约);9 门禁全绿;
OpenAIRawStream 保持基线 1091 行。
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.
用户报告:运行中频繁出现「运行工具失败 → 阻止了无效的工具调用」,集中在文件类工具。
根因(两个,均已修)
1. 内容嗅探路径静默替换空参数(GH#61/#83/#146 契约缺口)
ContentToolCallSniffer.argsOf在 arguments 串解析失败时返回空{}且不携带原始串。GH#113 类网关(工具调用经delta.content下发)上,每次调用都被必填字段预检拦成「无效工具调用」。SSE 与非流式路径早已按契约携带rawArgs,本 PR 把嗅探器补齐到同一契约:预检可尝试截断修复,修不了则给出带字节数的精确「参数流不完整」拒绝。2. 必填字段别名纠错缺失(模型习惯名)
ToolJsonRepair的字段名纠错只覆盖编辑距离 1 的拼写错(comand→command)。模型训练习惯名file_path→path(距离 6)救不回来——完整合法的载荷被必填校验判死。新增策略 4:枚举别名表(path/command/content/pattern/query/url/code/action/name/title/question 的常见变体),仅在必填字段缺失、且变体键不是本工具 schema 字段时改名(防 stealing)。验证