fix(hitl): 审批复盘轨迹补全 —— 中断不关 exec 流,resume 事件续录
现象:已完成的审批任务,复盘轨迹停在「已中断等待审批」、审批节点永远转圈,看着 像卡住(实际任务已 done、有输出)。 根因:任务中断时 Handle 的 defer tr.done() 给 exec 流发了 CompleteExec → 网关 exec 录制器关闭。resume 是另一次独立调用,其 exec 事件(审批通过/拒绝、续跑节点)发到 同一主题时录制器已关 → 没录进去。(token 流中断时特意没关,所以输出录到了;exec 流却被关了,不对称。) - exec.go: execTracer 加 suspended 标志,done() 挂起时不关流。 - orchestrator.go: 中断分支置 tr.suspended=true(与 token 流一致)。 - ExecTrace.tsx: 前端兜底——运行已完成(phase done)时把悬挂的 waiting/running 节点 收敛为 done,修旧任务(已 done、轨迹缺 resume 事件)的转圈假象。 live 验证:审批任务批准后复盘轨迹完整呈现 approval await→end「批准:放行」→ agent start→推理→end,审批节点不再转圈。 Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
This commit is contained in:
@@ -266,7 +266,8 @@ func (o *Orchestrator) Handle(ctx context.Context, t *contract.Task) error {
|
||||
if errors.Is(err, errInterrupted) {
|
||||
// HITL 持久化中断:checkpoint 已落、任务停在 waiting(状态在审批节点内已置)。
|
||||
// 释放 goroutine 但不收尾——不 CompleteStream、不评测、不判 done、不计熔断失败;
|
||||
// SSE 流保持打开,UI 继续显示待审。人工决定到达后由 resume 续跑(增量3)。
|
||||
// token 流与 exec 流都保持打开(suspended),resume 时续录,否则复盘里审批节点永停在等待中。
|
||||
tr.suspended = true
|
||||
slog.InfoContext(ctx, "task interrupted for approval (checkpointed)", "task_id", t.ID)
|
||||
o.breaker.Report(true) // 中断是正常暂停,非后端故障
|
||||
return nil
|
||||
|
||||
Reference in New Issue
Block a user