Skip to content

[Bug] send_message_to_user 莫名报 no such file,即使 file 存在且权限正确 #9626

Description

@Neclyon

Description

如题。
文件存在:

root@c07b606f5403:/AstrBot# ls -la /AstrBot/data/workspaces/_Peony_FriendMessage_3372728115/cash.py
-rwxrwxrwx 1 root root 1237 Aug 11 16:47 /AstrBot/data/workspaces/_Peony_FriendMessage_3372728115/cash.py

tool call 参数:

{"messages": [{"type": "file", "path": "/AstrBot/data/workspaces/_Peony_FriendMessage_3372728115/cash.py"}], "session": ""}

也没有错误。
但是工具调用返回:

ENOENT: no such file or directory

Reproduction Steps

在 aiocqhttp 平台部署 Docker 配置的 AstrBot V4.27.1 并在私聊中让其发送一个位于自己当前工作区的文件。

AstrBot Version

V4.27.1

Operating System

Linux

Deployment Method

Docker version 29.6.2, build dfc4efb1e2

Message Platform Adapter

Onebot (aiocqhttp) V11 with NapCat v4.18.9, QQ 3.2.28-48517.

Error Log

[2026-08-11 16:49:56.143] [Core]
[WARN]
[v4.27.1] [runners.tool_loop_agent_runner:1266]: Traceback (most recent call last):
  File "/AstrBot/astrbot/core/agent/runners/tool_loop_agent_runner.py", line 1148, in _handle_function_tools
    async for resp in self._iter_tool_executor_results(executor):  # type: ignore
  File "/AstrBot/astrbot/core/agent/runners/tool_loop_agent_runner.py", line 1502, in _iter_tool_executor_results
    yield next_result_task.result()
          ^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/AstrBot/astrbot/core/agent/runners/tool_loop_agent_runner.py", line 1472, in _next_executor_result
    return await anext(executor)
           ^^^^^^^^^^^^^^^^^^^^^
  File "/AstrBot/astrbot/core/astr_agent_tool_exec.py", line 185, in execute
    async for r in cls._execute_local(tool, run_context, **tool_args):
  File "/AstrBot/astrbot/core/astr_agent_tool_exec.py", line 666, in _execute_local
    resp = await asyncio.wait_for(
           ^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.12/asyncio/tasks.py", line 520, in wait_for
    return await fut
           ^^^^^^^^^
  File "/AstrBot/astrbot/core/astr_agent_tool_exec.py", line 807, in call_local_llm_tool
    ret = await ready_to_call
          ^^^^^^^^^^^^^^^^^^^
  File "/AstrBot/astrbot/core/tools/message_tools.py", line 338, in call
    await context.context.context.send_message(target_session, message_chain)
  File "/AstrBot/astrbot/core/star/context.py", line 537, in send_message
    await platform.send_by_session(session, message_chain)
  File "/AstrBot/astrbot/core/platform/sources/aiocqhttp/aiocqhttp_platform_adapter.py", line 119, in send_by_session
    await AiocqhttpMessageEvent.send_message(
  File "/AstrBot/astrbot/core/platform/sources/aiocqhttp/aiocqhttp_message_event.py", line 175, in send_message
    await cls._dispatch_send(bot, event, is_group, session_id, [d])
  File "/AstrBot/astrbot/core/platform/sources/aiocqhttp/aiocqhttp_message_event.py", line 113, in _dispatch_send
    await bot.send_private_msg(
  File "/usr/local/lib/python3.12/site-packages/aiocqhttp/__init__.py", line 236, in call_action
    return await self._api.call_action(action=action, **params)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.12/site-packages/aiocqhttp/api_impl.py", line 178, in call_action
    result = await self._wsr_api.call_action(action, **params)
             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.12/site-packages/aiocqhttp/api_impl.py", line 153, in call_action
    return _handle_api_result(await
           ^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.12/site-packages/aiocqhttp/api_impl.py", line 38, in _handle_api_result
    raise ActionFailed(result=result)
aiocqhttp.exceptions.ActionFailed: <ActionFailed status='failed', retcode=1200, data=None, message="ENOENT: no such file or directory, open '/AstrBot/data/workspaces/_Peony_FriendMessage_3372728115/cash.py'", wording="ENOENT: no such file or directory, open '/AstrBot/data/workspaces/_Peony_FriendMessage_3372728115/cash.py'", echo={'seq': 40}, stream='normal-action'>

Supplementary Information

No response

Checklist

  • I have searched the Issue list for related issues and could not resolve the problem, or this issue has never been reported before.
  • I have tried disabling all plugins to rule out issues caused by plugins.
  • The issue I am reporting is related to AstrBot itself, not to a specific plugin.
  • I have read and agree to the project's Code of Conduct.
  • (Optional) I am willing to submit a PR to help fix this issue.

Metadata

Metadata

Assignees

No one assigned

    Labels

    area:platformThe bug / feature is about IM platform adapter, such as QQ, Lark, Telegram, WebChat and so on.bugSomething isn't working

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions