auto-sync: 2026-05-15 12:32:02
This commit is contained in:
@@ -645,30 +645,73 @@ async def watch_signals():
|
||||
- Gateway WS `sessions.delete` 需要 `operator.admin` scope(token 模式不授予,不可用)❌
|
||||
- 回退方案:直接编辑 `sessions.json` 是安全可靠的 ✅
|
||||
|
||||
### 4.4 Agent Spawn 后的消息内容
|
||||
### 4.4 Agent Spawn 的上下文分层传递(课题 2 设计决策)
|
||||
|
||||
Agent 被 spawn 时,daemon 传递的消息应包含足够的上下文让 agent 知道该做什么:
|
||||
> **设计推导**:GSD Wave Execution 证明隔离 session + 新鲜 context > 单一 session + 压缩。Claude Code 的 file reference 模式证明“引用而非内联”是最优策略。问题不是 context 不够大,而是信号噪声比。
|
||||
|
||||
**D2-5:三层上下文传递(L1 必传 / L2 按需 / L3 按需)**
|
||||
|
||||
| 层级 | 内容 | Token 估算 | 谁决定 |
|
||||
|------|------|-----------|--------|
|
||||
| **L1(spawn message)** | 任务核心 + 角色 + 触发原因 + 依赖状态 + 最近评论 + must_haves | ~300-500 | Daemon 自动 |
|
||||
| **L2(CLI 按需)** | 完整评论线程 + 产出摘要 + 决策记录 + 观察记录 | ~500-1500 | Agent 自主决定 |
|
||||
| **L3(文件按需)** | 产出物文件完整内容 + 完整事件日志 + 子任务详情 | ~2000-10000 | Agent 自主决定 |
|
||||
|
||||
**L1 Spawn Message 模板**:
|
||||
|
||||
```python
|
||||
def build_spawn_message(task_id: str, trigger_reason: str, comments_since: str = None):
|
||||
def build_spawn_message_L1(task_id: str, agent_id: str, trigger: str) -> str:
|
||||
task = get_task(task_id)
|
||||
|
||||
# 依赖状态摘要(1行/依赖任务)
|
||||
deps_status = []
|
||||
for dep_id in json.loads(task['depends_on'] or '[]'):
|
||||
dep = get_task(dep_id)
|
||||
deps_status.append(f" {dep_id}: {dep['status']} - {dep['title']}")
|
||||
|
||||
# 最近 3 条评论摘要(截断 100 字符)
|
||||
recent_comments = get_comments(task_id, limit=3)
|
||||
comments_str = ""
|
||||
for c in recent_comments:
|
||||
comments_str += f" [{c['created_at'][:16]} {c['author']}] {c['body'][:100]}\n"
|
||||
|
||||
# must_haves 摘要
|
||||
must_haves = json.loads(task.get('must_haves') or '{}')
|
||||
truths_str = ', '.join(must_haves.get('truths', []))
|
||||
|
||||
return f"""黑板任务通知(L1):
|
||||
任务:{task['title']}({task['id']})
|
||||
状态:{task['status']} | 类型:{task['task_type']} | 风险:{task['risk_level']}
|
||||
触发原因:{trigger}
|
||||
描述:{task['description'] or '(无)'}
|
||||
验收标准(truths):{truths_str or '(未定义)'}
|
||||
|
||||
msg = f"黑板任务通知:\n"
|
||||
msg += f"- 任务:{task.title}({task.id})\n"
|
||||
msg += f"- 状态:{task.status}\n"
|
||||
msg += f"- 触发原因:{trigger_reason}\n"
|
||||
依赖状态:
|
||||
{chr(10).join(deps_status) if deps_status else ' (无依赖)'}
|
||||
|
||||
if comments_since:
|
||||
recent = get_comments_since(task_id, comments_since)
|
||||
if recent:
|
||||
msg += f"\n最近评论:\n"
|
||||
for c in recent:
|
||||
msg += f" [{c.created_at} {c.author}] {c.body[:200]}\n"
|
||||
最近评论:
|
||||
{comments_str if comments_str else ' (无评论)'}
|
||||
|
||||
msg += f"\n请读取黑板获取完整信息。"
|
||||
return msg
|
||||
请使用以下命令获取更多信息:
|
||||
L2(扩展):blackboard.py read --task {task_id} --level L2
|
||||
L3(全量产出):blackboard.py read --task {task_id} --type outputs
|
||||
"""
|
||||
```
|
||||
|
||||
**D2-6:不需要 Auto-compact**:v2.6 的 Agent 每次 spawn 都是隔离的新鲜 session,天然没有 context rot。唯一可能有累积的是庞统主 session(长期在线协调),属 Phase 3 优化。
|
||||
|
||||
**D2-7:Context 预算分配**(128K 模型):
|
||||
|
||||
| 组件 | 预算 | 说明 |
|
||||
|------|------|------|
|
||||
| System Prompt + SOUL.md + IDENTITY.md | ~3K-5K tokens | 固定开销 |
|
||||
| Skills + AGENTS.md | ~2K-4K tokens | 固定开销 |
|
||||
| L1 spawn message | ~300-500 tokens | 必传 |
|
||||
| L2 黑板扩展(按需) | ~500-1500 tokens | Agent 自主决定 |
|
||||
| L3 产出物文件(按需) | ~2K-10K tokens | Agent 自主决定 |
|
||||
| 工作空间(Agent 思考+输出) | ~30K-50K tokens | 预留 |
|
||||
| **总计** | **~40K-70K tokens** | 远小于 128K,安全 |
|
||||
|
||||
### 4.5 续杯与心跳
|
||||
|
||||
参考 v1.0 实践 + Hermes v0.13 Claim TTL。
|
||||
|
||||
Reference in New Issue
Block a user