Repository navigation
Conversation
consumeEventStream checked the abort signal only after each reader.read(), so when one network chunk carried several events and an onEvent callback aborted after the first, the remaining events of that chunk were still delivered. Check the signal before dispatching each decoded event so the result no longer depends on how the transport splits the stream. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
RGB-loop
marked this pull request as ready for review
October 15, 2026 13:41
This branch has not been deployed
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.
Problem
consumeEventStream(used bystreamEventsandcreateSessionStream) checksoptions.signalbetween reads, but not between events decoded from the same chunk. When one network chunk carries several events and anonEventcallback aborts after the first, the remaining events decoded from that same chunk are still delivered toonEvent. If the same events arrive in separate chunks, only the first is delivered. So what a caller sees afterabort()depends on how the transport happens to split the stream.This only affects callers that abort from inside
onEvent/onSession(or code those callbacks call synchronously). Aborts from outside the callbacks, such as an effect cleanup, already land between reads and were handled correctly before this change.Reproduction (before this change, main
afa07974)Injected
fetchreturning two validagent.session.turn.output_text.deltaframes;onEventcallscontroller.abort(reason):evt_1,evt_2evt_1Change
Check the signal before dispatching each decoded event (
throwIfAborted, same behavior as the existing post-read check: the call rejects with the abort reason and the reader is cancelled). No protocol or decoder change.Validation
client.test.ts: fails on main (expected ['evt_1','evt_2'] to deeply equal ['evt_1']), passes with the change; it also asserts the rejection reason and reader cancellation.pnpm --filter @oac/agents-client test: 22 files, 745 tests passed.pnpm --filter @oac/agents-client typecheck: passed.Limits: verified with injected
fetch/ReadableStreamonly;apps/webtests were not run because the change only affects behavior after the caller has already aborted.🤖 Generated with Claude Code
Need help on this PR? Tag
@codesmith-botwith what you need.