Skip to content

增强对于FileUploadTool和FileDownloadTool的descriptions,以解决基本上所有FileUploadTool被调用为FileDownloadTool导致沙盒无法访问上传文件问题#6501

Closed
guiyuanyuanbao wants to merge 1 commit intoAstrBotDevs:masterfrom
guiyuanyuanbao:6497-bugfileuploadtoolfiledownloadtool

Conversation

@guiyuanyuanbao
Copy link
Copy Markdown

@guiyuanyuanbao guiyuanyuanbao commented Mar 17, 2026

Fixes #6497

Modifications / 改动点

增强对于FileUploadTool和FileDownloadTool的descriptions,以解决基本上所有FileUploadTool被调用为FileDownloadTool导致沙盒无法访问上传文件问题

  • This is NOT a breaking change. / 这不是一个破坏性变更。

Screenshots or Test Results / 运行截图或测试结果

image ---

Checklist / 检查清单

  • 😊 If there are new features added in the PR, I have discussed it with the authors through issues/emails, etc.
    / 如果 PR 中有新加入的功能,已经通过 Issue / 邮件等方式和作者讨论过。

  • 👀 My changes have been well-tested, and "Verification Steps" and "Screenshots" have been provided above.
    / 我的更改经过了良好的测试,并已在上方提供了“验证步骤”和“运行截图”

  • 🤓 I have ensured that no new dependencies are introduced, OR if new dependencies are introduced, they have been added to the appropriate locations in requirements.txt and pyproject.toml.
    / 我确保没有引入新依赖库,或者引入了新依赖库的同时将其添加到 requirements.txtpyproject.toml 文件相应位置。

  • 😮 My changes do not introduce malicious code.
    / 我的更改没有引入恶意代码。

Summary by Sourcery

Clarify the intended usage and data flow directions of the file upload and download tools to reduce misuse and sandbox file access issues.

Enhancements:

  • Improve FileUploadTool description to emphasize its role in transferring existing local files into the sandbox and not for exporting sandbox results.
  • Improve FileDownloadTool description to emphasize its role in retrieving existing sandbox files to the local filesystem and not for providing input files to the sandbox.

@auto-assign auto-assign bot requested review from Fridemn and LIghtJUNction March 17, 2026 08:51
@dosubot dosubot bot added the size:S This PR changes 10-29 lines, ignoring generated files. label Mar 17, 2026
@gemini-code-assist
Copy link
Copy Markdown
Contributor

Summary of Changes

Hello, I'm Gemini Code Assist1! I'm currently reviewing this pull request and will post my feedback shortly. In the meantime, here's a summary to help you and other reviewers quickly get up to speed!

此拉取请求通过改进 FileUploadToolFileDownloadTool 的描述来解决一个关键问题。之前,由于工具描述不够清晰,导致系统经常错误地将文件上传工具识别为文件下载工具,从而使得沙盒无法正确访问用户上传的文件。本次更新旨在通过提供更详细、更明确的工具用途说明,确保这些文件操作工具能够被准确无误地调用,从而提升沙盒文件管理的可靠性和用户体验。

Highlights

  • 增强工具描述: 增强了 FileUploadTool 的描述,明确了其用于将本地文件上传到沙盒,并强调不应用于从沙盒下载文件。
  • 增强工具描述: 增强了 FileDownloadTool 的描述,明确了其用于将沙盒文件下载到本地,并强调不应用于向沙盒提供本地输入文件。
  • 解决工具误用问题: 解决了因工具描述不清导致 FileUploadTool 被错误调用为 FileDownloadTool,从而造成沙盒无法访问上传文件的问题。
Changelog
  • astrbot/core/computer/tools/fs.py
    • 更新了 FileUploadTooldescription 属性,使其更清晰地说明了文件上传的方向和使用场景。
    • 更新了 FileDownloadTooldescription 属性,使其更清晰地说明了文件下载的方向和使用场景。
Activity
  • 拉取请求由 guiyuanyuanbao 创建,旨在解决文件工具描述不清导致的问题。
Using Gemini Code Assist

The full guide for Gemini Code Assist can be found on our documentation page, here are some quick tips.

Invoking Gemini

You can request assistance from Gemini at any point by creating a comment using either /gemini <command> or @gemini-code-assist <command>. Below is a summary of the supported commands on the current page.

Feature Command Description
Code Review /gemini review Performs a code review for the current pull request in its current state.
Pull Request Summary /gemini summary Provides a summary of the current pull request in its current state.
Comment @gemini-code-assist Responds in comments when explicitly tagged, both in pull request comments and review comments.
Help /gemini help Displays a list of available commands.

Customization

To customize Gemini Code Assist for GitHub experience, repository maintainers can create a configuration file and/or provide a custom code review style guide (such as PEP-8 for Python) by creating and adding files to a .gemini/ folder in the base of the repository. Detailed instructions can be found here.

Limitations & Feedback

Gemini Code Assist may make mistakes. Please leave feedback on any instances where its feedback is incorrect or counter productive. You can react with 👍 and 👎 on @gemini-code-assist comments. If you're interested in giving your feedback about your experience with Gemini Code Assist for GitHub and other Google products, sign up here.

You can also get AI-powered code generation, chat, as well as code reviews directly in the IDE at no cost with the Gemini Code Assist IDE Extension.

Footnotes

  1. Review the Privacy Notices, Generative AI Prohibited Use Policy, Terms of Service, and learn how to configure Gemini Code Assist in GitHub here. Gemini can make mistakes, so double check it and use code with caution.

Copy link
Copy Markdown
Contributor

@sourcery-ai sourcery-ai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hey - I've left some high level feedback:

  • Consider standardizing the terminology for the two environments (e.g., always LOCAL vs SANDBOX, and clarifying whether LOCAL means the server filesystem or the end-user’s device) to avoid ambiguity for different deployment models.
  • To further reduce misuse, you might explicitly mention a concrete scenario in each description (e.g., 'when the model needs to read a local dataset file, use upload' vs 'when returning a generated report or log file to the user, use download') so the intent is crystal clear.
Prompt for AI Agents
Please address the comments from this code review:

## Overall Comments
- Consider standardizing the terminology for the two environments (e.g., always `LOCAL` vs `SANDBOX`, and clarifying whether `LOCAL` means the server filesystem or the end-user’s device) to avoid ambiguity for different deployment models.
- To further reduce misuse, you might explicitly mention a concrete scenario in each description (e.g., 'when the model needs to read a local dataset file, use upload' vs 'when returning a generated report or log file to the user, use download') so the intent is crystal clear.

Sourcery is free for open source - if you like our reviews please consider sharing them ✨
Help me be more useful! Please click 👍 or 👎 on each comment and I'll use the feedback to improve your reviews.

Copy link
Copy Markdown
Contributor

@gemini-code-assist gemini-code-assist bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code Review

本次 PR 旨在通过增强 FileUploadToolFileDownloadTooldescription 来解决 LLM 在选择工具时混淆上传和下载操作的问题。新的描述明确了文件传输的方向(例如 LOCAL -> SANDBOX),阐述了各自的适用场景,并加入了反向约束(例如,上传工具不应用于下载)。这些改动清晰、准确,能够有效引导 LLM 做出正确的工具选择,从而修复了描述中提到的问题。代码实现上没有问题。

@dosubot dosubot bot added the area:core The bug / feature is about astrbot's core, backend label Mar 17, 2026
@dosubot
Copy link
Copy Markdown

dosubot bot commented Mar 17, 2026

Related Documentation

1 document(s) may need updating based on files changed in this PR:

AstrBotTeam's Space

pr4697的改动
View Suggested Changes
@@ -127,8 +127,8 @@
   - `EXECUTE_SHELL_TOOL`:在沙盒环境中执行 Shell 命令
   - `PYTHON_TOOL`:在沙盒环境中执行 Python 代码
     - 工具描述中包含当前操作系统信息(通过 `platform.system()` 获取),帮助 LLM 生成与平台兼容的代码
-  - `FILE_UPLOAD_TOOL`:上传文件到沙盒环境
-  - `FILE_DOWNLOAD_TOOL`:从沙盒环境下载文件
+  - `FILE_UPLOAD_TOOL`(`astrbot_upload_file`):上传文件从本地文件系统到沙盒环境(方向:LOCAL → SANDBOX)。仅在源文件已在本地机器上且沙盒需要它作为输入时使用。不应用于从沙盒检索/导出结果。
+  - `FILE_DOWNLOAD_TOOL`(`astrbot_download_file`):从沙盒环境下载文件到本地文件系统(方向:SANDBOX → LOCAL)。当文件已存在于沙盒中且用户想要检索、导出或接收它时使用。不应用于向沙盒提供本地输入文件。
 
 - **`runtime="local"`** 或 **`runtime="local_sandboxed"`** 提供以下工具:
   - `LOCAL_EXECUTE_SHELL_TOOL`:在本地环境中执行 Shell 命令
@@ -253,6 +253,8 @@
 - 工具图片缓存(`data/temp/tool_images/`)在沙箱中可见,便于多模态任务处理
 
 该配置确保了本地和沙箱环境之间的文件共享机制正常工作,提升了文件传输工具的可用性。
+
+> **注意**:[PR #6501](https://github.com/AstrBotDevs/AstrBot/pull/6501) 增强了 `FILE_UPLOAD_TOOL` 和 `FILE_DOWNLOAD_TOOL` 的工具描述,明确了它们的方向性用法(LOCAL → SANDBOX 用于上传,SANDBOX → LOCAL 用于下载),防止工具混用导致的沙箱文件访问问题。该增强解决了用户因混淆上传和下载操作而导致沙箱无法访问上传文件的常见问题。
 
 ##### 流式响应配置(PR #5348)
 

[Accept] [Decline]

Note: You must be authenticated to accept/decline updates.

How did I do? Any feedback?  Join Discord

@RC-CHN
Copy link
Copy Markdown
Member

RC-CHN commented Mar 18, 2026

已合并有相同功能的pr #6527,仍然感谢您为改进astrbot做出的贡献

@RC-CHN RC-CHN closed this Mar 18, 2026
@guiyuanyuanbao guiyuanyuanbao deleted the 6497-bugfileuploadtoolfiledownloadtool branch March 18, 2026 02:28
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

area:core The bug / feature is about astrbot's core, backend size:S This PR changes 10-29 lines, ignoring generated files.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Bug]基本上所有FileUploadTool被调用为FileDownloadTool导致沙盒无法访问上传文件(个人认为非模型问题)

2 participants