摘要
bus_share_to_team 這支 MCP 工具的文件(docstring)宣稱可以用兩種方式指定要分享的檔案:「a path in your own workspace」或「an attachment file_id ('att_...')」。但實際測試發現:透過團隊聊天室訊息夾帶進來的附件,用它自己的 att_ file_id 呼叫這支工具會回「file not found」——即使那個附件確實存在、agent 也能正確讀出它的 file_id 與檔名。
根因是兩套完全不同的附件儲存機制被當成同一套處理:
- 團隊聊天室的附件上傳(
POST /{team_id}/chat/attachments)把檔案存進 {base}/{user_id}/_shared/bus_files/(docstring 原文:「so every team agent can Read it」)。
bus_share_to_team 解析 att_ file_id 時呼叫的 resolve_attachment_path(),只會去掃 {base}/{agent_id}_{user_id}/user_upload_files/{date}/ 這個完全不同的目錄(單一 agent 1:1 對話附件用的舊系統),對 _shared/bus_files 一無所知。
結果是:agent 最自然會想「分享」的檔案——使用者剛在團隊房間貼給大家看的那個附件——反而是這支工具唯一分享不了的檔案類型。
重現步驟
環境:https://dev-agent.narra.nexus,測試團隊 team_54f412ee0b4c,agent qa-tcjob06-test(agent_df94a825fc13)
- xyzdev01 在團隊房間(
team_54f412ee0b4c)發訊息時夾帶一個附件(qa-attachment-test.txt)
- 請 qa-tcjob06-test 讀出這則訊息附件的 file_id → 正確讀到
att_a1db55c9(name=qa-attachment-test.txt)
- 請 qa-tcjob06-test 呼叫
bus_share_to_team(team_id="team_54f412ee0b4c", file_path="att_a1db55c9")
- 回傳
{"success": false, "error": "file not found: att_a1db55c9"}
對照組(同一輪測試,Bash 建立的 workspace 檔案走「path」變體):bus_share_to_team(file_path="qa-workspace-test/hello.txt") 正確成功——所以問題精準落在「att_ file_id」這個變體,且落在「團隊聊天室來源的附件」這個子情境。
程式碼層根因
src/xyz_agent_context/message_bus/_bus_attachment_impl.py::_resolve_ref_to_source():is_valid_file_id(ref) 為真時,呼叫 resolve_attachment_path(sender_agent_id, owner_user_id, ref)。
src/xyz_agent_context/utils/attachment_storage.py::resolve_attachment_path():只在 get_workspace_path(agent_id, user_id) 底下的 user_upload_files/{date}/_index.json 找,這是 POST /api/agents/{agent_id}/attachments(單一 agent 1:1 對話附件上傳路由)寫入的位置。
backend/routes/teams.py::upload_team_chat_attachment()(POST /{team_id}/chat/attachments)docstring 明講:「The file lands in {base}/{user_id}/_shared/bus_files so every team agent can Read it」——完全不同的目錄,resolve_attachment_path() 從未查詢過這裡。
兩套附件系統的 att_ file_id 格式看起來一樣(is_valid_file_id 都能通過格式檢查),但物理位置跟索引檔完全不共用,bus_share_to_team 只認得其中一套。
影響
bus_share_to_team 的「attachment file_id」這個輸入方式,對團隊聊天室裡最常見的附件來源(使用者/agent 直接貼在團隊房間的檔案)完全不可用
- 使用者體感:明明檔案就在眼前的對話裡,agent 卻回報「找不到檔案」,令人困惑;且錯誤訊息沒有任何提示說明「請改用 workspace 相對路徑」這個可行的替代方案
- 「path」變體(workspace 相對路徑)本身運作正常,所以功能沒有完全失效,但工具文件宣稱的能力有一半打折扣
- severity:中——功能性缺口非安全問題,但直接命中這個功能存在的核心使用情境(PR #255 的設計初衷之一就是「把已經在聊天室裡的東西共享進團隊資料夾」)
測試環境
https://dev-agent.narra.nexus
- 對應測試計畫項目:
qa/features/collaboration-marketplace/test-plan-collaboration-marketplace.md TC-WORKSPACE-02
摘要
bus_share_to_team這支 MCP 工具的文件(docstring)宣稱可以用兩種方式指定要分享的檔案:「a path in your own workspace」或「an attachment file_id ('att_...')」。但實際測試發現:透過團隊聊天室訊息夾帶進來的附件,用它自己的 att_ file_id 呼叫這支工具會回「file not found」——即使那個附件確實存在、agent 也能正確讀出它的 file_id 與檔名。根因是兩套完全不同的附件儲存機制被當成同一套處理:
POST /{team_id}/chat/attachments)把檔案存進{base}/{user_id}/_shared/bus_files/(docstring 原文:「so every team agent can Read it」)。bus_share_to_team解析att_file_id 時呼叫的resolve_attachment_path(),只會去掃{base}/{agent_id}_{user_id}/user_upload_files/{date}/這個完全不同的目錄(單一 agent 1:1 對話附件用的舊系統),對_shared/bus_files一無所知。結果是:agent 最自然會想「分享」的檔案——使用者剛在團隊房間貼給大家看的那個附件——反而是這支工具唯一分享不了的檔案類型。
重現步驟
環境:
https://dev-agent.narra.nexus,測試團隊team_54f412ee0b4c,agentqa-tcjob06-test(agent_df94a825fc13)team_54f412ee0b4c)發訊息時夾帶一個附件(qa-attachment-test.txt)att_a1db55c9(name=qa-attachment-test.txt)bus_share_to_team(team_id="team_54f412ee0b4c", file_path="att_a1db55c9"){"success": false, "error": "file not found: att_a1db55c9"}對照組(同一輪測試,Bash 建立的 workspace 檔案走「path」變體):
bus_share_to_team(file_path="qa-workspace-test/hello.txt")正確成功——所以問題精準落在「att_ file_id」這個變體,且落在「團隊聊天室來源的附件」這個子情境。程式碼層根因
src/xyz_agent_context/message_bus/_bus_attachment_impl.py::_resolve_ref_to_source():is_valid_file_id(ref)為真時,呼叫resolve_attachment_path(sender_agent_id, owner_user_id, ref)。src/xyz_agent_context/utils/attachment_storage.py::resolve_attachment_path():只在get_workspace_path(agent_id, user_id)底下的user_upload_files/{date}/_index.json找,這是POST /api/agents/{agent_id}/attachments(單一 agent 1:1 對話附件上傳路由)寫入的位置。backend/routes/teams.py::upload_team_chat_attachment()(POST /{team_id}/chat/attachments)docstring 明講:「The file lands in{base}/{user_id}/_shared/bus_filesso every team agent can Read it」——完全不同的目錄,resolve_attachment_path()從未查詢過這裡。兩套附件系統的
att_file_id 格式看起來一樣(is_valid_file_id都能通過格式檢查),但物理位置跟索引檔完全不共用,bus_share_to_team只認得其中一套。影響
bus_share_to_team的「attachment file_id」這個輸入方式,對團隊聊天室裡最常見的附件來源(使用者/agent 直接貼在團隊房間的檔案)完全不可用測試環境
https://dev-agent.narra.nexusqa/features/collaboration-marketplace/test-plan-collaboration-marketplace.mdTC-WORKSPACE-02