父 Session 的子智能体状态使用一份只读投影,同时驱动 composer 实时入口、右上角摘要、
子智能体目录和失效 tab 清理。目录只展示当前有效 conversation branch 中能够可靠关联到
已持久化 subagent_child session 的 Agent/Task 调用,不创建占位 session,也不新增数据库表。
Workflow activity 不进入该投影,现有 Workflow 数据结构和交互保持不变。
child runtime ── persist subagent_child session ── SubagentSpawned/status/stopped
│
▼
CLI ProductProjection V4 snapshot.subagents
├─ revision
├─ childSessionIds[](当前 branch manifest)
├─ running[](完整、不分页)
└─ endedTotal
│
├─ desktop-continuous ────────────────┐
└─ web-remote-replayable snapshot/gap ├─ UI 纯消费
└─ UI 仅用 session/subagents 查询 ended 分页详情
snapshot.subagents 是当前 branch 的唯一运行态权威;composer 数量、状态摘要、运行项、
child tab 失效清理都直接消费该投影,不再另发 session/subagents 查询来重建 running 状态。session/subagents 仅消费已结束详情的 keyset 分页,不参与运行中成员计数或 tab
manifest;响应中的旧 running/manifest 字段只作协议兼容与 CLI 冷恢复校验,不再是 renderer 权威。SubagentSpawned 对外可见前,child session 必须已经持久化且可读取为
taskType=subagent_child。run、background start 和 resume 使用同一顺序,不允许投影先公布一个
尚不存在的 child,也不通过 renderer 延迟、轮询或切换 Session 自愈。同一次 CLI 投影提交原子更新 childSessionIds、running、endedTotal 和对应 Agent row;
UI 不在事件和查询之间做二次拼接。revision 只随该投影提交递增,迟到或重复 delta 不得回退状态。
active branch 使用 append-only transcript 的 keptMessageIDs + branchCutAfterMessageID 语义;
compact 只压缩 provider context,不删除目录成员。
edit/retry 移除的旧分支 child 立即退出投影;fork 继承复制 transcript 中可靠的已结束
childSessionId 引用,但不继承原 Session 的运行态。
关联优先读取 tool output/metadata 中的 childSessionId;foreground 完成结果只有稳定
agentId 时,按 Agent runtime 的正式 sess_subagent_{agentId} 身份规则构造并再次验证对应
session 确实存在且 taskType=subagent_child。运行中的 foreground 使用 parent event log 的
parentToolCallId -> childSessionId 关系,并且仍须命中 active branch tool call;不按标题、时间
或列表位置猜测。
已运行 child 在模型请求、工具或取消失败后通常已经持久化;若失败发生在首次持久化之前, 或历史记录无法可靠证明 child 关联,则不展示 stub。
running 包含 foreground、background、blocked 和 waiting;success、failed、cancelled、lost
统一属于 ended,每项继续保留具体状态。
冷恢复先从持久 transcript 重建 row,再以 session store 中已验证的
taskType=subagent_child 事实校验成员;旧历史里模糊、未持久或已被 branch cut 移除的引用不能进入
snapshot.subagents。运行中的恢复态由 runtime overlay 补齐,不能仅凭历史标题或时间猜测。
已结束查询响应携带独立查询 revision,使用稳定 keyset cursor、每页 20 条、最新优先。
snapshot.subagents.childSessionIds 是当前 branch 的 tab 失效清单,不是第二份展示数据。
mini capsule
├─ subagent-only -> 只统计 running subagent;不显示 ended;显示“{count} 运行”
└─ Bash/Subagent mixed -> 统计两类 running item;显示“{count} 运行”
expanded status panel
└─ 智能体(统一折叠分组,标题尾部显示“{count} 运行”)
├─ 正在运行 -> 现有运行项,可直接打开 child 详情;可控 background 项保留 Stop
└─ 已结束 · N -> 打开或复用 Subagent 目录 tab
Subagent directory(桌面 / 普通 Web)
├─ 正在运行(不分页)
└─ 已结束 · N
├─ newest first
└─ 再显示 20 个
snapshot.subagents.running 的成员数量,表达当前仍在运行的
subagent 数量;不得显示为“{count} 后台”,因为该集合同时包含 foreground、background、
blocked 和 waiting。snapshot.subagents.running 作为 child 身份和展示事实,但 Stop
控制权继续来自父 snapshot 的 backgroundWorks。两者只能按完全相同的 childSessionId
关联;命中 status=running、kind=subagent 且有 workId、cancellable !== false 时显示
Stop,并继续发送 cancelBackgroundWork(workId)。Stop 必须阻止详情点击冒泡;没有可靠
background work 关联的 foreground child 不显示伪造的单项 Stop,也不得按标题或时间猜测。endedTotal;目录随后按 ended-only
查询把该项合并到顶部,但保留已加载页面和滚动位置。subagent-directory:{workspaceKey}:{rootSessionId}:{parentSessionId};child tab 为
subagent-session:{workspaceKey}:{rootSessionId}:{childSessionId}。/remote 不提供目录;Agent/Task 和 Running 行仍可在现有右侧抽屉打开 child 详情。desktop-continuous,手机继续使用 web-remote-replayable;两端消费同一 V4
snapshot.subagents,手机重连仍由既有 snapshot/gap 恢复。ended-only 查询通过当前 trusted host
attachment 到同一 CLI/runtime,不在 relay、desktop main 或 Host 增加状态。workspaceIdentity 和 remoteSessionId;身份 key 始终为
workspaceIdentity?.trim() || workspacePath。DESIGN.md 的 surface/text/border/semantic token,兼容 Zai Light/Dark。