Skip to content

Finish a response stream only after its transcript entries are committed - #224

Merged
mattt merged 1 commit into
mainfrom
stream-finish-order
Sep 10, 2026
Merged

mattt merged 1 commit into
mainfrom
stream-finish-order

Conversation

@mattt

@mattt mattt commented Sep 10, 2026

Copy link
Copy Markdown
Collaborator

Follow-up to #181 (Copilot's one finding there, which predates that PR).

wrapStream reported completion before appending the response, and since #181 the streamed tool entries, to the session transcript. A caller that drains the stream and immediately starts the next turn could build its prompt from an incomplete transcript. Now the entries are committed and isResponding is cleared first, then the stream finishes, on both the success and the error path.

Default suite: 340 tests pass locally.

wrapStream reported completion before appending the response
(and, since #181, the streamed tool entries) to the session transcript,
so a caller that drains the stream and immediately starts the next turn
could build its prompt from an incomplete transcript.
Commit the entries and clear isResponding first, then finish the stream,
on both the success and the error path.
@mattt
mattt merged commit aace12e into main Sep 10, 2026
11 checks passed
@mattt
mattt deleted the stream-finish-order branch September 10, 2026 16:53
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