Implements orchestrator-only auto-continuation for incomplete todo lists with strict safety controls so automation does not loop or fight the user. It also hosts todo-state hygiene reminders after relevant tool actions.
index.ts exports createTodoContinuationHook(ctx, config?), returning:
handleMessagesTransformhandleChatSystemTransformhandleToolExecuteAfterhandleEventhandleChatMessagehandleCommandExecuteBeforetool map containing auto_continueContinuationState) tracks:
todo-hygiene.ts owns lightweight reminder arming/injection using
todo-queue transitions and message-context signals.handleMessagesTransform to avoid duplicate
per-request work.handleMessagesTransform identifies the latest external user message,
infers session/agent, and starts a new continuation cycle for orchestrator
sessions.session.idle/idle session.status, if enabled, the hook validates:
incomplete todos, non-question last assistant message, max-continuation limit,
suppress/notification guard, and timer/injection state.session.prompt.CONTINUATION_PROMPT via session.prompt, updates
consecutiveContinuations, and logs progress.session.deleted, orchestrator session state is torn down and notification
state is cleared.handleCommandExecuteBefore intercepts /auto-continue before runtime
execution.on, off, or flip), clears timers as needed,
and injects a direct status response into output parts.createTodoHygiene.handleToolExecuteAfter arms reminders after supported
tooling activity, with reset/ignore rules for specific tools.createTodoHygiene.handleChatSystemTransform injects one reminder per request
when open todos remain (TODO_HYGIENE_REMINDER or
TODO_FINAL_ACTIVE_REMINDER).handleEvent clears hygiene state on session.deleted.src/index.ts across:
experimental.chat.messages.transformexperimental.chat.system.transformchat.messagecommand.execute.beforeeventtool.execute.afterlog, createInternalAgentTextPart, and
SLIM_INTERNAL_INITIATOR_MARKER.session.message events and
maintained in the plugin for serve-mode routing consistency.