Repository navigation
Claude/stream prefix dedup main - #549
Merged
Wang-Daoji merged 4 commits intoSep 28, 2026
Merged
Conversation
Streaming text reaches a client over two independent paths: the live in-memory push and the transcript-file replay. Both deliver the same chunk to the same buffer, and stream content is appended rather than replaced, so a re-delivery doubles the visible text. The frame carried no position identity, leaving each client to guess — the CLI compared head/tail text overlap, the GUI did neither. Stamp a `transcript_offset` on every persisted record: the line's starting byte position, which is the pre-write file size because appends land at the end. Live delivery and file replay then share one identity for a chunk, and dedup becomes a numeric comparison. The stamp lands only after the write succeeds. Stamping first would let a failed write broadcast an offset that was never persisted, advancing the client watermark to a value the next real record also starts at — dropping new content instead of a duplicate. - transcript.ts: stamp the offset inside the single write path, so both delivery paths inherit it and no caller has to cooperate. - websocket.ts: stop cloning before persisting so the broadcast payload and the stored record are one object; always copy in sendTurnPayload so the caller's payload is not mutated by the stamp. - tui-gateway-client.ts: skip frames at or below the applied offset, falling through to the overlap heuristic for records written before this field. - agent-chat-slice.ts: hold a per-chat watermark, dropped and advanced by delta / reasoning_delta / stream_end, and re-based on a full hydrate so a rebuilt transcript cannot be swallowed by a stale watermark. Records written before this change carry no offset and keep their previous behaviour, so no migration is needed. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
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.
No description provided.