fix(coding-agent): pause auto-continue and todo reminders when assistant ends turn with a question#896
Open
tvrmsmith wants to merge 2 commits intocan1357:mainfrom
Open
Conversation
…ant ends turn with a question Auto-continue (post-compaction) and todo-reminder injections fired unconditionally, causing the agent to answer its own pending questions and barrel ahead instead of yielding for user input. Add assistantMessageEndsWithQuestion() predicate that detects either an ask tool call or a tool-call-free turn whose final text ends in '?' (after stripping trailing closing punctuation). Gate both auto-continue and todo-reminder paths on it. Expose ask.pauseOnQuestion setting (default true) so behavior can be opted out.
Verifies that when the assistant ends a turn with a question and there are incomplete todos, ask.pauseOnQuestion suppresses the todo reminder and prevents auto-continue, so the agent yields for user input.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Problem
When the assistant ends a turn with a question to the user, two harness paths can inject a developer prompt that causes the agent to answer its own question and barrel ahead instead of yielding for input:
#scheduleAutoContinuePrompt(post-compaction,agent-session.ts) queuesauto-continue.md(a "Resume work" developer prompt) unconditionally after compaction completes.#checkTodoCompletion(post-turn, when todos remain incomplete) queues a "you stopped with N incomplete todo(s)" reminder, compounded bysystem-prompt.md's rule that a todo flip is not a yield point.Reproduced in a real session (
~/.omp/agent/sessions/-dev-personal-superset/2026-04-30T16-29-37-326Z_*.jsonl):The session contained 4 prior
asktool calls — all were waited on correctly. The bug only manifested at the one turn where the agent asked in plain text instead of via theasktool.Fix
New exported pure predicate
assistantMessageEndsWithQuestion(msg)inpackages/coding-agent/src/session/agent-session.ts:trueif the last assistant turn contains anasktool call (the canonical structured form), ORtrueif the turn has no tool calls and the final text block ends in?after stripping trailing closing punctuation ([\s)\]}"'\*_]+`).asktool call beats a trailing?(control isn't being handed back to the user).Both gates short-circuit when the predicate fires AND
ask.pauseOnQuestionis enabled:#scheduleAutoContinuePrompt's inner schedule callback returns early before queuingauto-continue.md.#checkTodoCompletionreturns early before incrementing the reminder counter or queuing the reminder.Both gated paths log via
logger.debugrather than warn — this is expected behavior, not an anomaly.User-facing setting
ask.pauseOnQuestion(boolean, defaulttrue,interactiontab, label "Pause On Pending Question"). Set tofalseto restore the previous behavior.System-prompt nudge
One bullet added to
<output-contract>insystem-prompt.md: prefer theasktool for finite-choice decisions; for open-ended questions, end the turn with the question and yield — don't queue further work, mark todos done, or speculate an answer until the user replies. The plain-text?heuristic is a safety net; the structuredasktool is the primary path.Verification
packages/coding-agent/test/assistant-message-ends-with-question.test.ts): 11 cases covering ask-tool turns, plain-text questions with whitespace/closing-punctuation tails, multi-text-block ordering (uses last block only), declarative turns, empty content, and the tool-call priority rule. All pass.agent-session-eager-todo,agent-session-auto-compaction-queue,agent-session-auto-compaction-x-initiator— 22/22 pass.bun run check:ts— clean across all workspaces.extensions-discovery.test.ts(verified by stashing this change and re-running against the same baseline).Files
packages/coding-agent/src/session/agent-session.ts— predicate + private wrapper + two gate sitespackages/coding-agent/src/config/settings-schema.ts—ask.pauseOnQuestionsettingpackages/coding-agent/src/prompts/system/system-prompt.md—<output-contract>bulletpackages/coding-agent/test/assistant-message-ends-with-question.test.ts— new test (11 cases)