Repository navigation
Read only the transcript lines Claude Code has finished writing - #3700
Merged
Merged
Conversation
The Claude Code journey reads the session's transcript while Claude Code is still writing it, and a half-written last line failed the journey with a JSONDecodeError. native_records now leaves out a last line with no newline yet; the next read picks it up once it is complete. Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]>
leaf-agent
reviewed
Oct 23, 2026
leaf-agent
left a comment
Collaborator
There was a problem hiding this comment.
A partial UTF-8 character at the end of the transcript still makes this reader fail: read_text() raises UnicodeDecodeError before the unfinished line can be discarded. I reproduced this with one complete JSON line followed by an unfinished record ending in the first byte of a two-byte character. Split the bytes at the last newline before decoding the complete records.
A partial UTF-8 character at the end of the transcript failed the read before the unfinished line could be left out. Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]>
leaf-agent
approved these changes
Oct 23, 2026
max-sixty
added a commit
that referenced
this pull request
Oct 23, 2026
The Claude Code journey's transcript reads still failed with `JSONDecodeError: Unterminated string`, after #3700. The cause was not a half-written last line, as #3700 assumed. Claude Code writes U+2028 and U+2029 raw inside JSON strings, which JSON allows, and both readers split the transcript with `splitlines()`, which breaks a line at those characters. A transcript kept from a failed run held one U+2028 and one U+2029: 113 newlines, but 115 lines to `splitlines()`. Both readers now share `reply_phases.transcript_records`: - `journey_claude_code.native_records` reads the journey's session. - `claude_code_transcript` reads a session for `leaf-dev response-times`. It splits only at the newline Claude Code writes after each record, and keeps #3700's rule of leaving out a record still being written. The transcript test now holds a raw U+2028 inside a string. It fails without the fix and passes with it. This follows up #3700, the transcript-read fix from Max's decision #46 on the overnight report. `leaf.event_log.jsonl_line` already escapes these characters in the page log for the same reason. > _This was written by Claude Code on behalf of max-sixty_ --------- Co-authored-by: Claude Opus 5.5 (1M context) <[email protected]>
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.
The Claude Code journey reads the session's transcript while Claude Code is still writing it, between steps and as it breaks a reply down. When the read caught a record half-written, the last line didn't parse, and the journey failed with a
JSONDecodeErroreven though the session itself was fine. That happened twice in one batch of #46 benchmark runs.native_recordsnow decodes only the bytes up to the last newline, leaving out the record that isn't finished. Those bytes can end inside a character, so it splits before decoding. The next read picks the record up once Claude Code finishes writing it. The transcript test now ends its file in a half-written record cut inside a two-byte character. It fails without the fix and passes with it.This is the transcript-read fix from Max's decision #46 on the overnight report. The #46 experiment itself stays unmerged on
opening-progress-experiment.