发生了什么
在启用 Agent Sandbox 后,模型通过浏览器工具生成截图,再调用 astrbot_download_file 并设置 also_send_to_user=True 发送给用户时,.png 截图会被 AstrBot 组装为文件消息发送。
在 OneBot v11 / aiocqhttp 对接 NapCat 的场景下,该消息表现为文件发送,客户端侧没有按图片消息展示。实际使用中会出现模型日志提示文件已发送,但私聊中没有看到图片消息,NapCat 日志显示为 [文件发送中]。
如何重现
- 使用 OneBot v11 / aiocqhttp 接入 NapCat。
- 启用 AstrBot Agent Sandbox。
- 在会话中让模型使用浏览器工具访问页面并截图,例如生成
ciallomeow_result_rerun.png。
- 让模型调用
astrbot_download_file,参数包含:
{
"remote_path": "ciallomeow_result_rerun.png",
"also_send_to_user": true
}
- 观察 NapCat 与聊天客户端中的消息类型。
预期行为
当下载文件扩展名是常见图片格式时,例如 .png、.jpg、.jpeg、.gif、.webp、.bmp,astrbot_download_file 应按 AstrBot 的图片消息组件发送,使 OneBot/NapCat 适配器按图片消息处理。
普通文件仍应保持文件消息发送行为。
实际行为
图片文件被按文件消息发送。NapCat 侧日志显示文件发送,聊天客户端中未按图片消息展示。
日志
[Core] [INFO] [runners.tool_loop_agent_runner:1025]: 使用工具:astrbot_execute_browser_batch,参数:{'commands': ['click @e8', 'wait 1500', 'snapshot -i -C', 'screenshot ciallomeow_result.png'], ...}
[Core] [INFO] [runners.tool_loop_agent_runner:1222]: Tool `astrbot_execute_browser_batch` Result: ... "Screenshot saved to ciallomeow_result.png" ...
[Core] [INFO] [runners.tool_loop_agent_runner:1025]: 使用工具:astrbot_download_file,参数:{'remote_path': 'ciallomeow_result_rerun.png', 'also_send_to_user': True}
[Core] [INFO] [runners.tool_loop_agent_runner:1222]: Tool `astrbot_download_file` Result: File downloaded successfully ... and sent to user.
NapCat:
发送 -> 私聊 (...) [文件发送中]
运行环境
AstrBot: v4.23.5
Sandbox: Shipyard Neo
Platform: OneBot v11 / aiocqhttp
OneBot implementation: NapCat
补充说明
本地验证显示,astrbot_download_file 在 also_send_to_user=True 时根据文件扩展名选择消息组件即可修复该问题:图片后缀使用 Image.fromFileSystem(local_path),其他文件继续使用 File(name=name, file=local_path)。
参与贡献
发生了什么
在启用 Agent Sandbox 后,模型通过浏览器工具生成截图,再调用
astrbot_download_file并设置also_send_to_user=True发送给用户时,.png截图会被 AstrBot 组装为文件消息发送。在 OneBot v11 / aiocqhttp 对接 NapCat 的场景下,该消息表现为文件发送,客户端侧没有按图片消息展示。实际使用中会出现模型日志提示文件已发送,但私聊中没有看到图片消息,NapCat 日志显示为
[文件发送中]。如何重现
ciallomeow_result_rerun.png。astrbot_download_file,参数包含:{ "remote_path": "ciallomeow_result_rerun.png", "also_send_to_user": true }预期行为
当下载文件扩展名是常见图片格式时,例如
.png、.jpg、.jpeg、.gif、.webp、.bmp,astrbot_download_file应按 AstrBot 的图片消息组件发送,使 OneBot/NapCat 适配器按图片消息处理。普通文件仍应保持文件消息发送行为。
实际行为
图片文件被按文件消息发送。NapCat 侧日志显示文件发送,聊天客户端中未按图片消息展示。
日志
运行环境
补充说明
本地验证显示,
astrbot_download_file在also_send_to_user=True时根据文件扩展名选择消息组件即可修复该问题:图片后缀使用Image.fromFileSystem(local_path),其他文件继续使用File(name=name, file=local_path)。参与贡献