Skip to content

fix(session): resume loop when user message arrives during question prompt - #46139

Open
TheMrClaus wants to merge 1 commit into
anomalyco:devfrom
TheMrClaus:question-message-abort
Open

fix(session): resume loop when user message arrives during question prompt#46139
TheMrClaus wants to merge 1 commit into
anomalyco:devfrom
TheMrClaus:question-message-abort

Conversation

@TheMrClaus

@TheMrClaus TheMrClaus commented Aug 29, 2026

Copy link
Copy Markdown

Issue for this PR

Closes #46135

Type of change

  • Bug fix
  • New feature
  • Refactor / code improvement
  • Documentation

What does this PR do?

Repro: run the agent until it blocks on an interactive question tool prompt, then submit a new message instead of answering inline. The message gets persisted, but the session never resumes — the engine just hangs with no error.

Root cause: the question tool parks the session run inside Question.ask() on a pending deferred. A new prompt is persisted before the loop is invoked, but because the session is already running the fresh runLoop work is ignored — so the existing run stays stuck in the question wait forever, and nothing ever consumes the new message. No step-finish, no abort, no error event.

Fix: when a fresh prompt is persisted, reject any pending questions for that session. The processor's Question.RejectedError handler then checks whether a newer user message exists; if one does, the loop is allowed to continue — the tool settles, history reloads, and the queued message is processed as the next turn. Dismissing the prompt without a newer message still stops the run, same as before.

How did you verify your code works?

Added a regression test: submit a prompt while a question tool is pending, then submit a second prompt. It asserts both prompt fibers complete, the second user message reaches the next LLM input, the question tool settles to an error state, and the pending-question list drains. Before the fix it hung with "timed out waiting for loop to resume"; after the fix it passes (~3s).

Typecheck (tsgo --noEmit) is clean. I also ran the full package suite: 3353 pass, 43 fail — the failures are pre-existing environment issues on this machine (subprocess tests can't find bare bun on PATH; a host-umask assertion expects 0644 vs 0664), unrelated to this change.

Screenshots / recordings

N/A — not a UI change.

Checklist

  • I have tested my changes locally
  • I have not included unrelated changes in this PR

@github-actions github-actions Bot added needs:compliance This means the issue will auto-close after 2 hours. and removed needs:compliance This means the issue will auto-close after 2 hours. labels Aug 29, 2026
@github-actions

Copy link
Copy Markdown
Contributor

Thanks for updating your PR! It now meets our contributing guidelines. 👍

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.

Sending a message while the question-tool prompt is open swallows the message and the session never resumes (v1.18.18)

1 participant