Skip to content

JiuwenSwarm is an intelligent AI Agent built on openJiuwen. It extends the powerful capabilities of large language models directly to your fingertips through various communication apps you use daily.

Python

fix: 修改send_file_to_user工具描述,提高工具调用准确性

ray_lecf3cbc99dbba
diff --git a/jiuwenclaw/agentserver/deep_agent/prompt_builder.py b/jiuwenclaw/agentserver/deep_agent/prompt_builder.py
index 9b5152272b..d5fd51b1d5 100644
--- a/jiuwenclaw/agentserver/deep_agent/prompt_builder.py
+++ b/jiuwenclaw/agentserver/deep_agent/prompt_builder.py
@@ -161,6 +161,15 @@ def _identity_prompt(language: str) -> PromptSection:
执行用户任务时产生的生成产物(如代码文件、文档、数据文件等),若用户未指定存放位置,请遵循以下规则:
- **通用产物**:非技能相关的生成产物必须放在 `{workspace_dir}` 下合适的位置,根据文件用途和项目结构合理组织路径,便于用户统一管理和访问
- **技能产物**:涉及技能(skill)执行的产物必须放在技能专属目录 `{skills_dir}/{{skill_name}}/` 下,并根据产物类型和用途在该目录下合理组织子目录,确保技能资源的独立性和可维护性
+
+## 文件发送
+
+当你的工具列表中存在 `send_file_to_user` 工具时,**必须**在以下场景主动调用该工具将文件发送给用户:
+- 任务完成后产生了需要交付给用户的文件(报告、文档、数据文件、图片等)
+- 用户明确请求下载、导出、发送文件
+- 用户询问生成的文件如何获取
+
+**调用方式**:使用文件的绝对路径作为参数调用 `send_file_to_user` 工具。
"""
else:
content = f"""
@@ -212,6 +221,15 @@ Common command differences:
Generated artifacts (code files, documents, data files, etc.) produced during user task execution should follow these placement rules unless the user specifies otherwise:
- **General Artifacts**: Non-skill-related artifacts must be placed in an appropriate location within `{workspace_dir}`, organized according to file purpose and project structure for unified user management and access
- **Skill Artifacts**: Artifacts from skill execution must be placed in the skill's dedicated directory `{skills_dir}/{{skill_name}}/`, with subdirectories organized by artifact type and purpose to ensure independence and maintainability
+
+## Sending Files
+
+When the `send_file_to_user` tool is available in your tool list, you **must** proactively invoke it in these scenarios:
+- Task completion produces files that need to be delivered to the user (reports, documents, data files, images, etc.)
+- User explicitly requests to download, export, or receive files
+- User asks how to obtain generated files
+
+**How to call**: Use the absolute file path(s) as the parameter to invoke the `send_file_to_user` tool.
"""
return PromptSection(
name="identity",
diff --git a/jiuwenclaw/agentserver/tools/send_file_to_user.py b/jiuwenclaw/agentserver/tools/send_file_to_user.py
index 31fc6c6620..95a211d0de 100644
--- a/jiuwenclaw/agentserver/tools/send_file_to_user.py
+++ b/jiuwenclaw/agentserver/tools/send_file_to_user.py
@@ -166,8 +166,10 @@ class SendFileToolkit:
make_tool(
name="send_file_to_user",
description=(
- "发送文件给用户。支持发送一个或多个文件。"
- "需要提供文件的绝对路径列表。"
+ "【文件发送工具】当需要将生成的文件、导出的数据、创建的文档等发送给用户时使用此工具。"
+ "使用场景包括:用户请求导出/下载文件、任务完成后需要交付文件、生成报告/文档后发送给用户。"
+ "参数格式:接受单个路径字符串或路径数组,路径必须是绝对路径。"
+ "示例:'/tmp/report.pdf' 或 ['/tmp/file1.csv', '/tmp/file2.xlsx']"
),
input_params={
"type": "object",
@@ -175,7 +177,12 @@ class SendFileToolkit:
"abs_file_path_list": {
"type": ["array", "string"],
"items": {"type": "string"},
- "description": "要发送的文件绝对路径列表",
+ "description": (
+ "要发送的文件绝对路径。"
+ "可以是单个路径字符串如 '/path/to/file.pdf',"
+ "或路径数组如 ['/path/file1.csv', '/path/file2.xlsx']。"
+ "支持任意文件类型(pdf、xlsx、docx、png、zip等)。"
+ ),
}
},
"required": ["abs_file_path_list"],