fix(interrupt): keep partial streamed reply when stopped mid-response - #52854
Merged
Conversation
Stopping a turn while the model is streaming (stop/esc to redirect) raised InterruptedError, set final_response to the throwaway "waiting for model response" sentinel, and persisted messages WITHOUT the assistant text that was already streamed to the screen. The next turn then had no record of the half-finished reply, so the model appeared to "forget" what it just said. Recover the on-screen text from _current_streamed_assistant_text in the InterruptedError branch and append it as the assistant turn (and surface it as final_response). The metadata sentinel is kept only when nothing was streamed yet, preserving the ACP/client suppression behavior. Completes the partial-stream recovery from 397eae5 (which wired the same _current_streamed_assistant_text salvage into the connection-failure twin but missed the user-interrupt path). The lossy handler dates to c98ee98.
Contributor
🔎 Lint report:
|
OutThisLife
enabled auto-merge
June 26, 2026 04:56
ethernet8023
approved these changes
Jun 26, 2026
OutThisLife
disabled auto-merge
June 26, 2026 05:04
4 tasks
waefrebeorn
pushed a commit
to waefrebeorn/slermes
that referenced
this pull request
Jul 2, 2026
…upt-partial-reply fix(interrupt): keep partial streamed reply when stopped mid-response
habarmc1223-sudo
pushed a commit
to habarmc1223-sudo/hermes-agent-fluxmem
that referenced
this pull request
Jul 8, 2026
…upt-partial-reply fix(interrupt): keep partial streamed reply when stopped mid-response
santhreal
pushed a commit
to santhreal/hermes-agent
that referenced
this pull request
Jul 13, 2026
…upt-partial-reply fix(interrupt): keep partial streamed reply when stopped mid-response
Gravezzz
pushed a commit
to Gravezzz/hermes-agent
that referenced
this pull request
Jul 21, 2026
…upt-partial-reply fix(interrupt): keep partial streamed reply when stopped mid-response
leewenjie
pushed a commit
to leewenjie/hermes-agent
that referenced
this pull request
Aug 7, 2026
…upt-partial-reply fix(interrupt): keep partial streamed reply when stopped mid-response
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.
Summary
Pressing stop/esc to redirect mid-response made the agent "forget" what it
was saying. When a turn is interrupted while the model is streaming,
InterruptedErrorwas caught,final_responsewas set to the throwaway"Operation interrupted: waiting for model response (Xs elapsed)."sentinel, andmessageswere persisted without the assistant text already streamed to thescreen. The next turn had no record of the half-finished reply, so the model
restarted blind — reported as "if I stop a message it forgets about it."
The fix recovers the on-screen text from
agent._current_streamed_assistant_textin the
InterruptedErrorbranch (agent/conversation_loop.py) and appends it asthe assistant turn, also surfacing it as
final_response. The metadata sentinelis kept only when nothing was streamed yet, so the ACP/client suppression
behavior (
INTERRUPT_WAITING_FOR_MODEL_PREFIXstartswith check) is unchanged.Root cause / history
except InterruptedErrorhandler wasintroduced in
c98ee9852("feat: implement interactive prompts for sudo password and command approval",
Feb 21 2026) with
final_response = "Operation interrupted."and no capture ofthe streamed text.
397eae5d9("fix: recover partial streamed content on connection failure", Apr 13 2026)
added the
_current_streamed_assistant_textsalvage, but only for thestream-failure twin — the user-interrupt branch right above it was never
wired up. This PR completes that work.
2394e1872(sentinel wording) and the refactors
053025238/
f5bd09af4only moved/renamed the handler.
Test plan
test_interrupt_during_stream_preserves_partial_assistant_text— partialreply is appended to history + returned as
final_response.test_interrupt_before_any_stream_keeps_sentinel— no streamed text fallsback to the metadata sentinel, tail stays the user turn.
partial_stream_finish_reason, turn_finalizer_interrupt_alternation,
interrupt_propagation, concurrent_interrupt — 60 passed).