Keep what arrived when a stream dies - #5072
Open
elias-ba wants to merge 1 commit into
Open
Conversation
|
I have enough context to render the review. The PR is entirely AI-assistant reliability plumbing: partial-response preservation on stream death, a stuck-message reaper, failure-category storage/broadcast, Security Review ✅
|
elias-ba
force-pushed
the
timeout-stuck-message-reaper
branch
from
August 15, 2026 22:50
01753c3 to
55042f3
Compare
elias-ba
force-pushed
the
timeout-keep-partial-response
branch
from
August 15, 2026 22:50
043e22e to
1bb4437
Compare
A reply the user watched appear was thrown away the moment the stream failed. Every event except the final one returned the accumulator unchanged, so the saved message was built entirely from a complete event that never came - the panel typed out an answer and then replaced it with a red box. The accumulator now carries the text as it arrives, and the yaml that workflow and global chat send ahead of the text. If the stream ends without completing, whatever did arrive is saved as an assistant message marked incomplete rather than discarded. It is deliberately not presented as a finished answer: the message carries the incomplete_response category, so the panel can show it as cut off and offer a retry. Job chat's suggested code is not recoverable this way and is not attempted. It is assembled from the tool call after the model finishes, so when a stream dies mid-answer the code does not exist yet on either side - there is nothing to save, rather than something being dropped. Chunks are prepended and reversed once at the end rather than appended to a growing binary, since a long reply arrives as thousands of them.
elias-ba
force-pushed
the
timeout-stuck-message-reaper
branch
from
August 15, 2026 23:40
55042f3 to
3abf115
Compare
elias-ba
force-pushed
the
timeout-keep-partial-response
branch
from
August 15, 2026 23:40
1bb4437 to
46eb44f
Compare
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.
Description
The saved message was built entirely from Apollo's
completeevent. If the stream died before that arrived, everything the user had just watched appear on screen was thrown away, including workflow YAML that had already been sent.The stream fold now keeps the text and the YAML as they arrive, and saves them if the
completeevent never comes. The message is marked as failed, so it reads as an interrupted answer rather than a finished one.Job chat's suggested code can't be rescued this way. It's assembled from a tool call that only completes when the model finishes, so mid-stream it doesn't exist on either side.
Closes #__
Validation steps
mix test test/lightning/ai_assistant/ai_assistant_test.exsAI Usage
Pre-submission checklist