Repository navigation
Replies: 1 comment
|
Solid proposal, and I agree with the direction of 备选 A (a new guard package, no core-loop change). When I traced the actual loop-control point, though, I found a concrete blocker that affects both options and is worth pinning down before writing the guard. The terminal point is not a pluggable "before finish" hook — it's a loop-local decision that can't be un-ended from outside. In if (turnEnds && this.inbox.nextStep.length === 0) {
await this.dispatch.serial('agent/turn-stopping', { turn, signal })
signal.throwIfAborted()
}
if (turnEnds && this.inbox.nextStep.length === 0) breakThe "终答判定" is the combination of
So "让循环多跑一步" cannot be achieved purely from a guard at The clean middleware-shaped place is actually the same one My read on what's actually needed:
Worth checking before committing: does the I'd be happy to help prototype the guard for the tool-driven path (non-invasive, |
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
多步任务中模型常在 todos 还有 pending/in_progress 时以纯文本收尾交棒,用户只能手动“继续”;期望终答前自动检查并提醒继续。
验收与细节
completed关闭前(agent/turn-stopping边界),若本会话todos投影还有pending/in_progress,harness 注回一条提醒并让同 turn 多跑一步;以下情况行为不变、直接关闭:无残留(全completed)、从未建清单(null)、组合未挂载tool-todo(key 缺席)。todos置为completed/ 说出不再继续的原因),模型坚持结束时 guard 不再阻拦(原因见备选 A 的第 2 点)。completed/null/ 未挂载tool-todo三个对照组断言请求数仍为 1 且无注入;同 turn 第二次到达关闭边界不断言再提醒。实现建议(已按当前源码核验修正)
todo-unfinished-reminder),监听agent/turn-stopping(serial,无next,payload 只有{agent, turn, signal}),读ctx.sessionProjections.stateOf(agent.session, 'todos')(tool-todo/src/index.ts:apply已注册该 key;key 缺席时stateOf返回undefined,按无残留放行)。有残留且本 turn 未提醒过,则agent.steer(...)注回提醒,每 agent 每 turn 最多一次。零侵入agent-loop、可随组合开关,符合“Plugins, not loop changes”。只进 base 组合,不进sdk-minimal(后者无tool-todo)。repeat-tool-reminder形态的两处差异(不可照搬):prependContext:turn-stopping是 serialvoid,没有可改写的 decision 对象;正确做法是agent.steer(reminder)(hooks-claude-code的Stop桥与loop.spec的/loop模式已有先例;经 inbox splice →user/message落盘,满足“Model-visible ⟺ logged”,无需新 session 事件)。source.kind:'user'复位:turn-stoppingpayload 无messages可扫;防刷屏改为按 turn 去重(WeakMap<Agent, lastRemindedTurn>),同 turn 只提醒一次。packages/core/agent-loop/src/agent.ts的终答判定内联检查——侵入核心,需同步改docs/architecture.md,重,不推荐。落地时别漏的边界
todos是 standing-plan 语义(turn/start清零):guard 只覆盖“同 turn 虎头蛇尾”;跨新 turn 后投影自然为null,按现有语义不算残留。concludesTurn的工具结果同样经过turn-stopping:guard 会提醒一次;想提前结束的工具调用前先把todos收尾,guard README 需写明。{kind:'plugin', plugin:'todo-unfinished-reminder', form:'notice', summary}且 summary 不超过 120 字符(CONTEXT_SUMMARY_MAX_CHARS),否则在派生历史里渲染异常。Config(“有残留即提醒”是固定规则,无证据不加可调量);inject = ['sessionProjections']硬依赖注册表,对todoskey 软处理(缺席即放行,覆盖 HMR 卸载场景)。All reactions