Sfoglia il codice sorgente

WIP: 验证群聊附件进入 Agent 上下文

[gstack-context]
Decisions: 回归测试覆盖服务端落盘路径进入 GroupStore projection 与 Agent GROUP_CONTEXT_JSON
Remaining: 用户在真机发送新附件做视觉与实际 Agent 工具读取验收
Skill: /investigate
[/gstack-context]
samien 2 mesi fa
parent
commit
7fe59e09ee

+ 35 - 3
hermes-plugins/yaoyao/dashboard/tests/test_group_topics_contract.py

@@ -58,8 +58,19 @@ class GroupTopicsContractTests(unittest.TestCase):
         )
 
     def test_group_upload_persists_server_readable_attachment(self) -> None:
-        room_id = new_id()
         with tempfile.TemporaryDirectory() as directory:
+            store = GroupStore(Path(directory) / "group.db")
+            store.initialize()
+            room = store.create_room(
+                {
+                    "requestId": new_id(),
+                    "name": "附件群",
+                    "cwd": "",
+                    "agents": [{"profile": "default"}],
+                }
+            )
+            [agent] = room["agents"]
+            room_id = room["id"]
             result = asyncio.run(
                 group_plugin_api._persist_group_uploads(
                     room_id,
@@ -70,13 +81,16 @@ class GroupTopicsContractTests(unittest.TestCase):
                             headers=Headers({"content-type": "image/png"}),
                         )
                     ],
-                    root=Path(directory),
+                    root=Path(directory) / "uploads",
                 )
             )
 
             [uploaded] = result
             path = Path(uploaded["path"])
-            self.assertEqual(path.parent, Path(directory).resolve() / room_id)
+            self.assertEqual(
+                path.parent,
+                Path(directory).resolve() / "uploads" / room_id,
+            )
             self.assertEqual(path.suffix, ".png")
             self.assertEqual(path.read_bytes(), b"fixture-image")
             self.assertEqual(path.stat().st_mode & 0o777, 0o600)
@@ -84,6 +98,24 @@ class GroupTopicsContractTests(unittest.TestCase):
             self.assertEqual(uploaded["mimeType"], "image/png")
             self.assertEqual(uploaded["size"], len(b"fixture-image"))
 
+            created = store.create_human_message(
+                room_id,
+                request_id=new_id(),
+                client_message_id=new_id(),
+                topic_id=new_id(),
+                content=f"请查看图片\n\n![photo.png](<{path}>)",
+                mention_agent_ids=[agent["id"]],
+            )
+            [run] = created["runs"]
+            self.assertEqual(store.claim_next_runnable_run()["id"], run["id"])
+            projection = store.read_run_projection(run["id"])
+            prompt = ORCHESTRATOR.build_run_prompt(
+                projection,
+                store.get_room(room_id)["agents"],
+            )
+            self.assertIn(str(path), prompt)
+            self.assertTrue(path.is_file())
+
     def test_group_upload_rejects_oversize_and_removes_partial_files(self) -> None:
         room_id = new_id()
         with (