Improve write_file fallback handling
This commit is contained in:
+14
-2
@@ -216,7 +216,19 @@ def get_using_your_tools_section(enabled_tool_names: set[str]) -> str:
|
||||
if 'edit_file' in enabled_tool_names:
|
||||
items.append('编辑文件时,优先使用 edit_file,而不是 shell 文本替换。')
|
||||
if 'write_file' in enabled_tool_names:
|
||||
items.append('创建文件时,优先使用 write_file,而不是 heredoc 或 echo 重定向;默认写入当前 session 目录。')
|
||||
items.append(
|
||||
'创建或追加通用文本文件时,优先使用 write_file,而不是 heredoc 或 echo 重定向;默认写入当前 session 目录。'
|
||||
)
|
||||
items.append(
|
||||
'write_file 支持 content、content_lines、content_base64 三种写入方式。多行脚本、Markdown、CSV 或包含较多引号的文本,优先用 content_lines,避免把大段带转义的内容塞进单个 JSON 字符串。'
|
||||
)
|
||||
items.append(
|
||||
'需要分批写入长文件时,使用 write_file 的 append=true 追加稳定文件;不要反复覆盖同一个中间产物。'
|
||||
)
|
||||
if 'python_exec' in enabled_tool_names:
|
||||
items.append(
|
||||
'如果 write_file 因内容过长、引号/换行转义复杂或工具参数生成失败而无法稳定完成写入,下一轮应优先改用 python_exec 写文件:把文本作为 stdin 或 Python 字符串/列表处理,并写入同一个 session 路径。'
|
||||
)
|
||||
if 'glob_search' in enabled_tool_names:
|
||||
items.append('搜索文件时,优先使用 glob_search,而不是 find 或 ls。')
|
||||
if 'grep_search' in enabled_tool_names:
|
||||
@@ -246,7 +258,7 @@ def get_using_your_tools_section(enabled_tool_names: set[str]) -> str:
|
||||
'当没有专用工具,或需要真实 shell 语义、系统命令、进程控制、git 只读检查或用户已确认的依赖安装时,可以使用 bash。'
|
||||
)
|
||||
if 'python_exec' in enabled_tool_names:
|
||||
items.append('当 python_exec 可用时,不要用 bash 执行 python、python3 或 .venv/bin/python。')
|
||||
items.append('当 python_exec 可用时,不要用 bash 执行 python、python3 或 .venv/bin/python;只有 python_exec 和专用文件工具都无法完成时,才把 bash 作为最后兜底。')
|
||||
items.append(
|
||||
'你可以在一次响应中调用多个工具。独立工具调用尽量并行,存在依赖关系的调用保持顺序执行。'
|
||||
)
|
||||
|
||||
Reference in New Issue
Block a user