Persist interrupted assistant output as authoritative session state - #5206
Merged
Hmbown merged 2 commits intoAug 3, 2026
Conversation
Copilot
AI
changed the title
[WIP] Add durable session item for interrupted assistant output
Persist interrupted assistant output as authoritative session state
Aug 3, 2026
Hmbown
marked this pull request as ready for review
August 3, 2026 12:48
Hmbown
deleted the
copilot/engine-make-interrupted-assistant-output-durable
branch
August 3, 2026 12:48
Contributor
There was a problem hiding this comment.
Pull request overview
This PR makes interrupted assistant output a durable, first-class session item so that text already streamed to the user is preserved in Engine session state, survives reopen/resume, and is included in subsequent model context with explicit “interrupted/incomplete” semantics.
Changes:
- Persist publicly streamed assistant text on interruption as an
assistant_interruptedsession message, emittingSessionUpdatedbefore returningTurnComplete(Interrupted). - Treat interrupted assistant items as assistant-like across the TUI (history, notifications, translation replacement) and tool-history repair logic.
- Serialize interrupted items into downstream model inputs (Chat/Responses/Anthropic) as assistant messages prefixed with explicit incomplete-context guidance.
Reviewed changes
Copilot reviewed 11 out of 11 changed files in this pull request and generated 2 comments.
Show a summary per file
| File | Description |
|---|---|
| crates/tui/src/core/engine/turn_loop.rs | Commits visible assistant text as an interrupted item on cancel/pause before returning Interrupted. |
| crates/tui/src/core/engine.rs | Adds add_interrupted_assistant_text with basic idempotency to persist interrupted text and emit session updates. |
| crates/tui/src/models.rs | Introduces INTERRUPTED_ASSISTANT_ROLE and an interrupted-context prefix constant; adds a serde round-trip test. |
| crates/tui/src/client/chat.rs | Includes interrupted assistant items in Chat serialization with explicit interrupted-context prefixing. |
| crates/tui/src/client/responses.rs | Includes interrupted assistant items in Responses input conversion and prefixes them for model context. |
| crates/tui/src/client/anthropic.rs | Maps interrupted assistant items to role: assistant and prefixes the first text block for model context. |
| crates/tui/src/tui/ui.rs | Allows assistant-text replacement logic to operate on interrupted assistant messages too. |
| crates/tui/src/tui/notifications.rs | Includes interrupted assistant items when generating “latest assistant text” notification previews. |
| crates/tui/src/tui/history.rs | Extends archived-context parsing to treat interrupted assistant messages as assistant-like. |
| crates/tui/src/tool_history_repair.rs | Treats interrupted assistant messages as assistant boundaries for tool call/result integrity repair. |
| crates/tui/src/session_manager.rs | Updates tests to accept interrupted assistant items as assistant-like where appropriate. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Comment on lines
+590
to
594
| if (msg.role == "assistant" | ||
| || msg.role == crate::models::INTERRUPTED_ASSISTANT_ROLE) | ||
| && let Some(archived) = parse_archived_context(text) | ||
| { | ||
| cells.push(archived); |
Comment on lines
+668
to
+672
| "assistant" | crate::models::INTERRUPTED_ASSISTANT_ROLE => { | ||
| for block in &msg.content { | ||
| match block { | ||
| ContentBlock::Text { text, .. } => { | ||
| let text = if msg.role == crate::models::INTERRUPTED_ASSISTANT_ROLE { |
Hmbown
pushed a commit
that referenced
this pull request
Aug 4, 2026
…5206) * Initial plan * WIP: persist interrupted assistant output --------- Co-authored-by: copilot-swe-agent[bot] <198982749+Copilot@users.noreply.github.com>
Hmbown
pushed a commit
that referenced
this pull request
Aug 4, 2026
…5206) * Initial plan * WIP: persist interrupted assistant output --------- Co-authored-by: copilot-swe-agent[bot] <198982749+Copilot@users.noreply.github.com>
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.
Interrupted assistant text was previously visible only to the client and absent from durable session history and subsequent model context. This change records that text as an explicit incomplete assistant item before
TurnComplete(Interrupted).Engine persistence
assistant_interruptedsession items containing only publicly streamed text.SessionUpdatedbefore the interrupted terminal event.Model context