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
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
elias-ba
force-pushed
the
timeout-stuck-message-reaper
branch
from
August 17, 2026 02:53
3abf115 to
d0b1213
Compare
elias-ba
force-pushed
the
timeout-keep-partial-response
branch
from
August 17, 2026 02:53
46eb44f to
34430bf
Compare
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## timeout-stuck-message-reaper #5072 +/- ##
============================================================
Coverage 90.5% 90.6%
============================================================
Files 422 422
Lines 20044 20066 +22
============================================================
+ Hits 18148 18175 +27
+ Misses 1896 1891 -5 ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
elias-ba
force-pushed
the
timeout-stuck-message-reaper
branch
from
August 17, 2026 04:10
d0b1213 to
8d50a20
Compare
elias-ba
force-pushed
the
timeout-keep-partial-response
branch
from
August 17, 2026 04:11
34430bf to
5bdb4ad
Compare
elias-ba
force-pushed
the
timeout-stuck-message-reaper
branch
from
August 17, 2026 09:24
8d50a20 to
abe0cd6
Compare
elias-ba
force-pushed
the
timeout-keep-partial-response
branch
2 times, most recently
from
August 17, 2026 16:47
9db7ecf to
6874963
Compare
7 tasks
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. Saving it is not enough on its own - the channel has to send it, before the error, or the client clears its buffer and the user only finds the reply again by reloading. Apollo's own words stay out of the panel and the row. Apollo wraps any unhandled exception as str(e), which carries internal hostnames, upstream URLs and container paths. That it failed is worth recording, because it separates a service giving up from a socket going quiet; its words are not, so they go to the log. 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 18, 2026 07:29
abe0cd6 to
43d8b43
Compare
elias-ba
force-pushed
the
timeout-keep-partial-response
branch
from
August 18, 2026 07:29
6874963 to
b990493
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
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
completeevent 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, so the panel can show it as cut off and offer a retry. The content is clamped to the column's limit, because a reply that ran past it would fail the changeset and lose the lot.
Saving it is not enough on its own. The channel has to send it, and send it before the error, or the client clears its streaming buffer and the user only finds the reply again by reloading. That is a new
new_messagebroadcast on the error path.Apollo's own words stop reaching the panel and the row. Apollo wraps any unhandled exception as
str(e), which carries internal hostnames, upstream URLs and container paths. That it failed is worth recording, because it separates a service giving up from a socket going quiet; its words are not, so they go to the log and the user gets a sentence of ours. Three existing tests changed with it, since they asserted on Apollo's text.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.
Validation steps
Additional notes for the reviewer
This is where Apollo's own error text stops reaching the panel. Three existing tests changed with it, since they asserted on Apollo's words.
AI Usage
Please disclose whether you've used AI anywhere in this PR (it's cool, we just want to know!):
You can read more details in our Responsible AI Policy
Pre-submission checklist
/reviewwith Claude Code):owner,:admin,:editor,:viewer)