From 8dac92aad2feee5de672c953783c2b1ba2b6843e Mon Sep 17 00:00:00 2001 From: cfdaily Date: Sat, 30 May 2026 10:25:46 +0800 Subject: [PATCH] auto-sync: 2026-05-30 10:25:46 --- src/daemon/ticker.py | 46 +++++++++++++++++++++++++++----------------- 1 file changed, 28 insertions(+), 18 deletions(-) diff --git a/src/daemon/ticker.py b/src/daemon/ticker.py index 70929eb..d3da121 100644 --- a/src/daemon/ticker.py +++ b/src/daemon/ticker.py @@ -1053,9 +1053,20 @@ Parent Task ID: {parent_task.id} def _build_claim_prompt(self, agent_id: str, tasks: list, project_id: str) -> str: - """构建广播认领的 prompt""" + """#03: 广播认领 prompt(身份+专长注入)""" api_host = getattr(self.spawner, 'api_host', '127.0.0.1') if self.spawner else '127.0.0.1' api_port = getattr(self.spawner, 'api_port', 8083) if self.spawner else 8083 + api_base = f"http://{api_host}:{api_port}/api" + + # 获取 Agent 专长 + caps = "通用" + try: + if self.dispatcher and self.dispatcher.router: + profile = self.dispatcher.router.agent_profiles.get(agent_id) + if profile and profile.capabilities_zh: + caps = ", ".join(profile.capabilities_zh) + except Exception: + pass task_list = "\n".join([ f"- ID: {t.id}, 标题: {t.title}, 类型: {getattr(t, 'task_type', '') or 'general'}, " @@ -1063,31 +1074,30 @@ Parent Task ID: {parent_task.id} for t in tasks ]) - return f"""你是 {agent_id}。黑板上有 {len(tasks)} 个待认领任务。 - -## 重要规则 -- 只认领符合你专长的任务。如果你不是最合适的执行者,不要认领 -- 认领后必须写产出物再转 review,不能无产出就提交 + return f"""你是 {agent_id},专长: {caps}。 ## 待认领任务 {task_list} -## 操作 -1. 读黑板查看详情: - curl http://{api_host}:{api_port}/api/projects/{project_id}/tasks?status=pending +## 规则 +- 只认领符合你专长的任务。你的专长是 {caps},不适合的任务不要认领 +- 不确定时不要认领,留给更合适的 Agent +- 认领后必须写产出物再转 review +- claim 失败说明已被别人认领,NO_REPLY 退出 -2. 选择适合你专长的任务并认领: - curl -X POST http://{api_host}:{api_port}/api/projects/{project_id}/tasks/TASK_ID/claim \\ - -H 'Content-Type: application/json' -d '{{"agent": "{agent_id}"}}' +## 你能做什么 +- 读任务详情: GET {api_base}/projects/{project_id}/tasks?status=pending +- 认领: POST {api_base}/projects/{project_id}/tasks/{{{{TASK_ID}}}}/claim + body: {{"agent": "{agent_id}"}} +- 认领后标 working: POST {api_base}/projects/{project_id}/tasks/{{{{TASK_ID}}}}/status + body: {{"status": "working", "agent": "{agent_id}"}} +- 没有适合你的任务则 NO_REPLY -3. 认领成功后开始执行: - curl -X POST http://{api_host}:{api_port}/api/projects/{project_id}/tasks/TASK_ID/status \\ - -H 'Content-Type: application/json' -d '{{"status": "working", "agent": "{agent_id}"}}' - -4. 没有适合你的任务则退出 +## 约束 +- 一个 tick 只认领一个任务 +- 禁止使用 sessions_send 直接发消息 """ - @property def counter(self): """从 Dispatcher 获取 counter""" return getattr(self.dispatcher, 'counter', None) if self.dispatcher else None