Skip to content

fix(core): start an interrupted stream over when the body read fails - #318

Merged
Max17190 merged 1 commit into
mainfrom
restart-interrupted-chunked-streams
Sep 8, 2026
Merged

Max17190 merged 1 commit into
mainfrom
restart-interrupted-chunked-streams

Conversation

@Max17190

@Max17190 Max17190 commented Sep 8, 2026 •

Copy link
Copy Markdown
Owner

Why

The restart for a stream the network cut before any reply text (from #316) only fired when the body ended cleanly with no completion signal. A read error on the body was treated as a decode failure and skipped, but every error the response body stream yields carries that label, and this client applies no content decoding that could fail on its own. Servers frame streams chunked, and a chunked or sized body cut short surfaces as a read error, not a clean end, so the fault the restart was written for still ended the turn with the task half done.

Summary

  • Every body read error now counts as an interruption and gets the same fresh attempt as a clean cut. Streams the client ends itself (size cap, tool index cap, cancellation) are unchanged and still never retried.
  • The test fixture that serves a sequence of bodies can frame one as Transfer-Encoding: chunked and close the socket after the first chunk, which is how a cut mid-reply reaches the client from a real server.

Test Plan

  • New a_stream_cut_mid_chunk_is_started_over: reasoning streamed in a chunked body that is cut, then a full reply on the next connection. Asserts two connections served, the retry announced between the reasoning and the reply, and the finished reply alone in the result. Fails on the previous code with one connection served and a truncated result.
  • cargo test --workspace --locked green (949); cargo +1.97.0 clippy --workspace --all-targets --locked -- -D warnings clean.

Greptile Summary

The client now recognizes a response-body read failure as an interrupted stream when no reply content has been emitted. The focused chunked SSE scenario confirms that reasoning from the failed attempt is followed by a retry notice and that the completed retry supplies the final reply.

Confidence Score: 5/5

Safe to merge.

The focused stream-retry coverage passed against the updated implementation and demonstrated recovery from a chunked response that closes before completion.

Files Needing Attention: None.

T-Rex T-Rex Logs

What T-Rex did

  • Compared the before and after evidence to verify that the change makes the command pass against the updated source.
  • Linked the exact before-run and after-run shell scripts to the proof to enable reproducibility.
  • Validated that the after-run log shows the required command passing against the changed source.

View all artifacts

T-Rex Ran code and verified through T-Rex

Reviews (1): Last reviewed commit: "fix(core): start an interrupted stream o..." | Re-trigger Greptile

The restart for a stream the network cut before any reply text only fired
when the body ended cleanly with no completion signal. A read error on the
body was skipped as a decode failure, but every error the response stream
yields carries that label, and this client applies no content decoding of
its own: a chunked or sized body cut short arrives exactly there. Servers
frame streams chunked, so the fault the restart was written for still
ended the turn.

Every body read error now counts as an interruption and gets the same
fresh attempt as a clean cut. The sequence fixture can frame a body
chunked and close after the first chunk; the new test streams reasoning
that way, is cut, and asserts the reply is started over on a second
connection with the retry announced in between. It fails on the previous
code with a single served connection and a truncated result.
@Max17190
Max17190 merged commit 3375123 into main Sep 8, 2026
11 checks passed
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.

1 participant