You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
reacted with thumbs up emoji reacted with thumbs down emoji reacted with laugh emoji reacted with hooray emoji reacted with confused emoji reacted with heart emoji reacted with rocket emoji reacted with eyes emoji
Uh oh!
There was an error while loading. Please reload this page.
摘要
continuable 后台子代理在 turn 结束时若调用了注入的
report工具(系统提示明确鼓励这么做),父会话会收到两条内容相同的投递:settle notice("finished … Its closing message: X")与 report relay("Background subagent <id> reported: X")。且顺序反转——notice 先到(notifySettlement对运行中的 parent 用Agent.steer→next-step即时注入),relay 后到(deliverReport用Agent.followup→next-turn排队,parent 当前 turn 结束后才显示,即原报告中的 "minutes later")。两条独立投递路径对同一份 child 输出无任何去重,调度策略不对称。复现步骤
backgroundMode: "continuable"(continuable 子代理,默认reportDelivery: "wakeup")。subagent工具run_in_background: true启动子代理。send_message跟进(消息在 child inbox 排队为下一 turn)。report工具交付结果 X("Deliver your result with the report tool before you finish"),随后 turn 正常结束。根因(源码定位,rc.6)
双投递路径、零去重 —
dsh-subagent/lib/index.js:reportFrom():907 →deliverReport():932-948(subagent-report/relay)→ 默认reportDelivery: "wakeup"(dsh-tool-subagent-report/lib/index.js:19)→sendReport():965-972 →parent.followup();finishDisposal():1396-1432(:1415observer.capture记录 epoch 最后 assistant 输出 → :1428notifySettlement())→ :1461-1467 无条件携带 closing output,:1479-1482 运行中 parent 走parent.steer();notifySettlement不感知 child 已 relay 过同一输出(Activation 无 delivered 标记,不查 parent inbox)。调度不对称导致顺序反转 —
dsh-agent-loop/lib/index.js:followup():396-397 →send(input, "next-turn", true):390-395:插入 inbox 尾部,当前 turn 结束后才处理;steer():399-401 →send(input, "next-step", true):插入当前 turn 待处理步骤前,立即处理;内容必然重复 — report 的 X 即 child 最终交付物;
observer.capture(:239-246)折叠同一 epoch 取最后 assistant 输出(同为 X)→ 两条消息正文相同。建议修复
方案 A(推荐)· 去重:
reportFrom/deliverReport成功时在 Activation 上记录已 relay(如reportedMessageId);notifySettlement检测到该 epoch 已 relay 相同输出时,省略 closing output(保留 summary + stopReason——notice 还承载终止语义,不能整条丢弃)。方案 B · 统一调度顺序:
notifySettlement不再对运行中 parent 用steer,与 relay 一样走followup(next-turn)→ 保证 FIFO:relay 先、notice 后,消除反转。方案 C · 可诊断性:重复投递时输出结构化日志(如
settlement notice duplicated relay output, omitted),便于编排会话识别过滤。影响
环境
run_in_background: true+ mid-flightsend_message+ 第 2 turn 完成后 settle)验证材料
dsh-subagent/lib/index.js:deliverReport :932-948 / notifySettlement :1451-1486 / finishDisposal :1396-1432 / capture :239-246;dsh-agent-loop/lib/index.js:send :390-395 / followup :396-397 / steer :399-401;dsh-tool-subagent-report/lib/index.js::19(reportDelivery默认wakeup)、:33(提示引导 child 结束前调 report);First analysis of discussion #2185. Happy to open a PR with fix option A.
All reactions