auto-sync: 2026-05-17 18:35:46
This commit is contained in:
+64
-27
@@ -21,7 +21,7 @@ logger = logging.getLogger("moziplus-v2.spawner")
|
||||
|
||||
# ── Prompt 模板 ──
|
||||
|
||||
SPAWN_PROMPT_TEMPLATE = """你收到一个 v2.6 黑板任务,请按步骤执行。
|
||||
SPAWN_PROMPT_TEMPLATE = """你收到一个 v2.6 黑板任务。请严格按照下面的步骤执行。
|
||||
|
||||
## 任务信息
|
||||
|
||||
@@ -33,47 +33,84 @@ SPAWN_PROMPT_TEMPLATE = """你收到一个 v2.6 黑板任务,请按步骤执
|
||||
- 优先级: {priority}
|
||||
- 必要条件: {must_haves}
|
||||
|
||||
{retry_context}
|
||||
|
||||
## 状态机(你必须遵守的状态流转)
|
||||
|
||||
```
|
||||
pending → claimed → working → review → done
|
||||
│ │
|
||||
│ └→ pending(驳回重做)
|
||||
├──→ failed
|
||||
├──→ blocked
|
||||
└──→ cancelled
|
||||
```
|
||||
|
||||
你当前处于 **{current_status}** 状态。
|
||||
|
||||
## 执行步骤
|
||||
|
||||
1. 了解任务需求,确认理解无误
|
||||
2. 执行任务(编码/回测/数据检查/审查等)
|
||||
### 步骤 1: 开始工作
|
||||
|
||||
## ⚠️ 完成后必须回写(关键!)
|
||||
立即调 API 标记你已开始:
|
||||
```bash
|
||||
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}"}}'
|
||||
```
|
||||
|
||||
你必须完成以下 API 调用才算任务完成。如果你只执行了步骤 1-2 但没有调 API 回写,任务将永远不会完成。
|
||||
### 步骤 2: 执行任务
|
||||
|
||||
根据任务描述完成你的工作(编码/回测/数据检查/审查等)。
|
||||
|
||||
### 步骤 3: 写入产出
|
||||
```
|
||||
POST http://{api_host}:{api_port}/api/projects/{project_id}/tasks/{task_id}/outputs
|
||||
Content-Type: application/json
|
||||
|
||||
{{"agent": "{agent_id}", "content": "<你的产出内容>", "content_type": "report"}}
|
||||
⚠️ 这一步是必须的!不写产出 = 任务没完成。
|
||||
|
||||
```bash
|
||||
curl -X POST http://{api_host}:{api_port}/api/projects/{project_id}/tasks/{task_id}/outputs \
|
||||
-H 'Content-Type: application/json' \
|
||||
-d '{{"agent": "{agent_id}", "type": "<产出类型>", "title": "<产出标题>", "content": "<你的产出内容>", "summary": "<简要说明>"}}'
|
||||
```
|
||||
|
||||
content_type 可选: "report"(文本报告), "code"(代码), "data"(数据路径), "file"(文件路径)
|
||||
**type 必须是以下之一**: code, document, data, config, other
|
||||
|
||||
### 步骤 4: 更新任务状态
|
||||
如果任务成功完成:
|
||||
```
|
||||
POST http://{api_host}:{api_port}/api/projects/{project_id}/tasks/{task_id}/status
|
||||
Content-Type: application/json
|
||||
|
||||
{{"status": "review", "agent": "{agent_id}"}}
|
||||
如果产出太长,可以写文件后用路径引用:
|
||||
```bash
|
||||
curl -X POST http://{api_host}:{api_port}/api/projects/{project_id}/tasks/{task_id}/outputs \
|
||||
-H 'Content-Type: application/json' \
|
||||
-d '{{"agent": "{agent_id}", "type": "code", "title": "main.py", "content_path": "/path/to/file.py", "summary": "主程序"}}'
|
||||
```
|
||||
|
||||
如果遇到问题无法完成:
|
||||
```
|
||||
POST http://{api_host}:{api_port}/api/projects/{project_id}/tasks/{task_id}/status
|
||||
Content-Type: application/json
|
||||
### 步骤 4: 提交审查或标记失败
|
||||
|
||||
{{"status": "failed", "agent": "{agent_id}", "detail": "<失败原因>"}}
|
||||
✅ 成功完成:
|
||||
```bash
|
||||
curl -X POST http://{api_host}:{api_port}/api/projects/{project_id}/tasks/{task_id}/status \
|
||||
-H 'Content-Type: application/json' \
|
||||
-d '{{"status": "review", "agent": "{agent_id}"}}'
|
||||
```
|
||||
|
||||
## 注意
|
||||
- API 地址: http://{api_host}:{api_port}
|
||||
- 查看完整任务信息: GET /api/projects/{project_id}/tasks/{task_id}?expand=all
|
||||
- 写入评论: POST /api/projects/{project_id}/tasks/{task_id}/comments
|
||||
- 产出写入后,审查流水线会自动触发
|
||||
❌ 无法完成:
|
||||
```bash
|
||||
curl -X POST http://{api_host}:{api_port}/api/projects/{project_id}/tasks/{task_id}/status \
|
||||
-H 'Content-Type: application/json' \
|
||||
-d '{{"status": "failed", "agent": "{agent_id}", "detail": "<失败原因>"}}'
|
||||
```
|
||||
|
||||
## Fallback(API 调用失败时)
|
||||
|
||||
如果 API 失败 2 次,尝试:
|
||||
```bash
|
||||
curl -X POST http://{api_host}:{api_port}/api/projects/{project_id}/tasks/{task_id}/status \
|
||||
-H 'Content-Type: application/json' \
|
||||
-d '{{"status": "failed", "agent": "{agent_id}", "detail": "API回写失败,产出在本地文件"}}'
|
||||
```
|
||||
|
||||
## 参考链接
|
||||
- 查看任务完整信息: GET http://{api_host}:{api_port}/api/projects/{project_id}/tasks/{task_id}?expand=all
|
||||
- 写评论: POST http://{api_host}:{api_port}/api/projects/{project_id}/tasks/{task_id}/comments {{"author": "{agent_id}", "body": "..."}}
|
||||
- 完整 API 契约: docs/design/agent-api-contract.md
|
||||
"""
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user