Repository navigation
Send a state answer's data sources only when the tab lacks that version - #3009
Merged
Merged
Conversation
Every /api/state read and every /api/event answer carried each data source's whole value, though data moves only when an agent sets it. Since #2929 added two Playwright trace manifests (~650 KB each, mostly saved accessibility trees) to the corpus, a comment there carried 1.4 MB back in its event answer, and again in the state read that often follows: 1.5 to 3 MB per comment. A state request now names the data version the tab holds in `Leaf-Data-Version`. When the answer's data is still that version, the server sends `data: {version}` without sources, and the reader restores the sources from the reading its request named (`completeData` in `layer-client.js`), so the reading stays exact even if another answer moved the tab's data in between. A request naming nothing, such as the first read, a saved website response or an export, still gets every source. On the corpus comment bench (3 runs, load 12-15), bytes per comment fell from ~2.2 MB to ~140 KB; timings did not move, since the main-thread cost is the state application, not the transfer or parse. Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]>
The table's request count and byte total said a corpus comment had grown from 4 requests and ~200 KB to 6-13 requests and 1.5-3 MB, but not which requests; finding them took a patch to the probe. results.json now records each request's URL, initiator and transferred bytes beside the totals. Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]>
leaf-agent
previously approved these changes
Oct 15, 2026
# Conflicts: # skills/leaf/kernel/kernel.json
leaf-agent
approved these changes
Oct 15, 2026
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.
Every
/api/stateread and every/api/eventanswer carried each data source's whole value, though data moves only when an agent sets it. Since #2929 added two Playwright trace manifests (~650 KB each, mostly saved accessibility trees) to the corpus example, a comment there carried 1.4 MB back in its event answer, and again in the state read that often follows: 1.5–3 MB per comment.A state request or event POST now names the data version the tab holds in
Leaf-Data-Version. When the answer's data is still that version,page_state(http.py) sendsdata: {version}without sources, and the reader restores them from the reading its request named (completeDatainlayer-client.js, used bystate-feed.jsanddelivery.js), so the reading stays exact if another answer moved the tab's data meanwhile. A request naming no version (the first read, website publications, exports, older vendored pages) still gets every source, so no protocol bump.Why this is for your review: it adds a wire mechanism, and it didn't move local timings: bytes per corpus comment fell from ~2.2 MB to ~140 KB, but painted and Sent stayed within noise, since the main-thread cost is applying the state, not transferring it. Its gain is on leaf.page, where the bytes cross a network. The alternative is to defer the trace manifests'
phasesthrough the existingrecords.deferredmechanism (as the diff package deferspatch), which would also take ~1.2 MB off the corpus's first state read, but changeslf-traceto fetch accessibility trees on demand. Codex's review found no correctness defects (every answer reader restores or gets full data; state answers areno-store), and noted the server still reads and hashes the sources each answer.Also:
bench-latency'sresults.jsonnow records each request a benched transition caused (URL, initiator, bytes), which is how the bytes were found.Checks:
pnpm run test:runtime,pnpm run check:framework, a new runtime test ("a read keeps the data it named…") and a server assertion, each failing with its half of the fix removed.