Skip to content

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
tvrmsmith:fix/pause-on-pending-question
Open

fix(coding-agent): pause auto-continue and todo reminders when assistant ends turn with a question#896
tvrmsmith wants to merge 2 commits intocan1357:mainfrom
tvrmsmith:fix/pause-on-pending-question

Conversation

@tvrmsmith
Copy link
Copy Markdown
Contributor

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) queues auto-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 by system-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):

17:22:13.???  assistant text ends with "Which do you want?" (no tool call)
17:22:13.+22  developer "Resume work" injected
17:22:18.???  assistant applies Option 1 unilaterally

The session contained 4 prior ask tool calls — all were waited on correctly. The bug only manifested at the one turn where the agent asked in plain text instead of via the ask tool.

Fix

New exported pure predicate assistantMessageEndsWithQuestion(msg) in packages/coding-agent/src/session/agent-session.ts:

  • Returns true if the last assistant turn contains an ask tool call (the canonical structured form), OR
  • Returns true if the turn has no tool calls and the final text block ends in ? after stripping trailing closing punctuation ([\s)\]}"'\*_]+`).
  • Tool calls take priority: a non-ask tool call beats a trailing ? (control isn't being handed back to the user).

Both gates short-circuit when the predicate fires AND ask.pauseOnQuestion is enabled:

  • #scheduleAutoContinuePrompt's inner schedule callback returns early before queuing auto-continue.md.
  • #checkTodoCompletion returns early before incrementing the reminder counter or queuing the reminder.

Both gated paths log via logger.debug rather than warn — this is expected behavior, not an anomaly.

User-facing setting

ask.pauseOnQuestion (boolean, default true, interaction tab, label "Pause On Pending Question"). Set to false to restore the previous behavior.

System-prompt nudge

One bullet added to <output-contract> in system-prompt.md: prefer the ask tool 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 structured ask tool is the primary path.

Verification

  • New unit test (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.
  • Adjacent suites: 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.
  • Full coding-agent test suite — 2786 pass / 27 fail / 400 skip. The 27 failures are pre-existing in 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 sites
  • packages/coding-agent/src/config/settings-schema.tsask.pauseOnQuestion setting
  • packages/coding-agent/src/prompts/system/system-prompt.md<output-contract> bullet
  • packages/coding-agent/test/assistant-message-ends-with-question.test.ts — new test (11 cases)

…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.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant