fix(skill): 修正 research-paper-writing 工具调用方式,修复 execute_code 不传 code#559
fix(skill): 修正 research-paper-writing 工具调用方式,修复 execute_code 不传 code#559ncw1992120 wants to merge 3 commits into
Conversation
…-writing The "Tool Usage Patterns" section taught the model wrong tool-call syntax that caused it to call execute_code without the required `code` parameter, producing "No code supplied" errors (issue mateaix#557). - execute_code: single positional string -> named params (language="python", code="...") as the schema requires - terminal(...) -> execute_shell_command(...) (no `terminal` tool exists) - delegate_task(...) -> delegateToAgent(agentName=..., task=...) (no `delegate_task` tool; delegateToAgent requires a positional agentName) - removed send_message(...) (no such tool) - web_extract -> web_search in delegate task descriptions - clarified the citation-verification code block as the code= body, not tool-call syntax Refs: mateaix#557
评审意见方向正确、单一关注点、替换的工具名已逐一核实为真:
必须修:改动不完整,同类误导源在同一文件里大量残留。 PR 只改了 2160-2192 行的两个 pattern 块,但对照 builtin 工具全量清单核查后,同文件还有以下残留(行号按 base):
SKILL.md 是整篇进模型上下文的,表格离修复处只有几行,误导权重不低于已修掉的示例。这些残留与本 PR 标题"修正工具调用方式"是同一关注点,应补进本 PR:
|
…SKILL.md Address PR review: the first commit only fixed the "Tool Usage Patterns" block, but the same file referenced many more non-existent tools. Map every tool reference to a real registered tool (verified against @tool definitions) and drop tools that have no equivalent. Tool table + Related Skills table: - terminal/process -> execute_shell_command (folded background-process usage) - patch -> edit_file - delegate_task -> delegateToAgent(agentName=..., task=...) - memory -> write_workspace_memory_file / search_workspace_memory - cronjob -> create_cron_job / list_cron_jobs - todo -> progress_update (closest real progress tracker) - web_extract -> web_search (+ browser_use for a specific page) - skill_view -> load_skill(skillName=...) - removed clarify / send_message rows (no equivalent tools) Body sections: - State Management: memory()/todo()/terminal() rewritten to real tools - Cron Monitoring: cronjob("create",{schedule,prompt}) -> create_cron_job(name=, cronExpression=, triggerMessage=) - Communication/Decision: send_message/clarify -> direct response guidance - scattered clarify/todo/web_extract/delegate_task refs corrected Documentation only; no logic change. Every tool name now resolves to a real @tool definition. Refs: mateaix#557
已按评审意见补全(新增 commit
|
| 原(不存在) | 改为(真实工具) |
|---|---|
terminal / process |
execute_shell_command(并入后台进程用法 nohup ... & / ps / kill) |
patch |
edit_file |
delegate_task |
delegateToAgent(agentName=..., task=...)(补回必填 agentName) |
memory |
write_workspace_memory_file / search_workspace_memory |
cronjob |
create_cron_job(name=, cronExpression=, triggerMessage=) / list_cron_jobs |
todo |
progress_update(stepKey=, label=, status=, note=)(最接近的真实进度跟踪器) |
web_extract |
web_search(+ browser_use 取特定页面) |
skill_view |
load_skill(skillName=...) |
clarify / send_message |
删除(无对应工具),改为「直接在回复中提问/告知」 |
覆盖范围
- 工具表格(Tools Reference)+ Related Skills 表
- State Management 段(
memory()/todo()/terminal()全部改写) - Cron Monitoring 段(
cronjob("create",{schedule,prompt})→create_cron_job(...)) - Communication / Decision Points 段
- 散布引用(:84 clarify、:157 todo、:248 terminal、:255 skill_view、:257/264 web_extract、:312 delegate_task)
验证
- 全文 grep 伪工具调用模式(
terminal(/delegate_task/web_extract/cronjob/send_message/skill_view/todo(/memory(等)已无残留 - 新引入的 15 个工具名逐一核对到
mateclaw-server/.../tool/builtin/下的@Tool定义
两处说明
skill_manage("install", "qmd")(Related Skills 表 qmd 行)保留未动:skill_manage是真实工具但用于 create/edit/patch/delete 技能内容,并无 "install" 动作;评审未列出此行,且我未核实到正确的「安装技能」写法,为避免引入新错误暂保留,欢迎指正。- 代码类改动(
@Tool描述警告 + sanitize「第三选项」+ 补 WARN)不在本 PR:按单一关注点原则,这些属服务端参数处理/模型引导,与文档修复分离,将另开后续 PR(见 [Bug] 模型调用 execute_code 不传 code 参数,报错 No code supplied #557 评论的调查结论)。
仍为纯文档改动,无逻辑变更。
复审(针对
|
Address PR review (复审) of the tool-name cleanup:
- browser_use is a structured tool whose first param `action` only accepts an
enum (start|stop|open|snapshot|...). The previous natural-language single
string bound to `action` and would fail — the same bug class this PR fixes.
Replace with the correct two-step form:
browser_use(action="open", url="...")
browser_use(action="snapshot")
- skill_manage has no "install" action (only create|edit|patch|delete); skill
installation is a marketplace/REST operation with no LLM-callable tool.
Reword the qmd row to "Install from the skill marketplace (ask the user),
then load_skill(skillName=\"qmd\")".
Documentation only.
Refs: mateaix#557
复审两处必改已落实(commit
|
背景
Fixes #557
模型在调用
execute_code工具时不传code参数,稳定报错No code supplied。根因是research-paper-writing技能的 "Tool Usage Patterns" 段落教了错误的调用方式——这是仓库里唯一演示execute_code实际调用的地方,且被标注为「最常见模式」,模型会模仿。改动
修正
research-paper-writing/SKILL.md的 "Tool Usage Patterns" 整段(2159–2200 行),使所有工具调用使用真实的工具名和正确的参数签名:execute_code("analyze results JSON, compute metrics")execute_code(language="python", code="...")language/code为命名参数,单位置字符串会被绑定为 null → "No code supplied"terminal(...)(×4)execute_shell_command(...)terminal工具(也无别名层),真实工具名为execute_shell_commandsend_message(...)delegate_task("...")(×3)delegateToAgent(agentName="...", task="...")delegate_task工具;delegateToAgent需两个必填位置参数,原写法漏了agentNameweb_extract(任务描述内)web_searchweb_extract工具# In execute_code:# Pass this as the code= argument to: execute_code(language="python", code=...)所有引用的工具名均可对应到
mateclaw-server/src/main/java/vip/mate/tool/builtin/下的@Tool定义:execute_shell_command(ShellExecuteTool)、execute_code(CodeExecuteTool)、delegateToAgent(DelegateAgentTool)、web_search(WebSearchTool)。关于 ISSUE 里的可选加固项(sanitizeToolCallArguments)
ISSUE 把「JSON 截断时保留已解析字段」列为可选项。调查后结论是不做——见 issue #557 的评论:部分解析会破坏下游截断检测(依赖参数是非法 JSON 才触发「缩短重发」指引)、有语义风险、且代码库无现成 lenient 解析器可复用。
{}替换是有意为之。验证
git diff确认改动仅限目标段落(2160–2192 行)@Tool定义且参数签名一致改动范围
单文件、纯文档修正,无逻辑变更: