Repository navigation
perf(remote): drop the tool bodies a phone never renders from the live lane - #870
Merged
Merged
Conversation
…e lane The lean feed dropped the two content streams but forwarded every other event verbatim, so a `write` still shipped the whole file it was about to write and an `edit` the text it replaced -- on the live lane, exactly as the history page had already stopped doing. A usage event still carried the provider's full report where the client reads one number out of it. `tool_start` now keeps only the argument keys a tool row's label is built from (`path`/`file_path`/`filePath`) for `write` and `edit`; `shell` keeps its `command` (it *is* the label) and `read` its few bytes, and a tool this build does not know keeps everything, because nothing here can tell which of its arguments a future client reads. `usage` keeps `completion_tokens` -- the one number the phone sums into a settled reply's footer, with `agent_end` as its documented fallback -- and drops the counters and credit cost that only the desktop footer shows (the desktop reads the agent, not this lane). Measured on the three heaviest completed runs, through the shipping trims: | run | coalesced lane before | after | saved | |---|---:|---:|---:| | 1 | 764,398 B | 607,798 B | -20.5% | | 2 | 767,459 B | 586,864 B | -23.5% | | 3 | 441,876 B | 369,437 B | -16.4% | What the lane carries now is per-tool-call metadata (46-53%), outcomes (15-18%), usage (12-14%), thinking boundaries (16-17%) and visible text (2-6%).
huichen
enabled auto-merge (squash)
September 26, 2026 07:48
huichen
added a commit
that referenced
this pull request
Sep 26, 2026
The live lane still streamed every shell call's command, the largest single thing it had left (~18%). The history page dropped it long ago and posts the client to `get_tool_call_args` when a row is opened; this does the same on the live lane, which is what the row's identity is now for. Client: a live tool activity carries `toolCallId` and the run it streamed under, the same pair the persisted projection attaches. Without them the row would be permanently blank once its target is gone -- `ToolRow` only offers the fetch when it has both. Trim: `shell` keeps nothing but its identity on `tool_start`. `read` keeps its path (the row's own label) and `write`/`edit` the path alone, as before; a tool this build does not know still keeps everything. The price, measured rather than assumed: the client exempts a bare `grep`/`diff`/`test` exiting 1 from being shown as a failure, and its predicate reads the command. The agent sends the same verdict as `is_soft_fail` on the outcome (both predicates agree, and the field has been on the wire since 2026-08-19), so the exemption normally needs nothing else. A row from an agent predating that field now reads as failed instead. Over 20,332 real shell results every `exit_code: 1` without the flag was a genuine failure -- a piped or `&&` chain, or a program outside the soft-fail set -- so the shape this costs is one the running agent does not produce. The render checks assert the price explicitly, and the full-feed control shows the other reading side by side. Measured through `scripts/measure/measure-live-lane.py` on the three heaviest completed runs: | | events | undeclared | coalesced | lean before | lean now | this PR | |---|---:|---:|---:|---:|---:|---:| | 1 | 174,791 | 77.21 MB | 5.33 MB | 379,915 B | 188,061 B | -50.5% | | 2 | 166,685 | 73.19 MB | 5.07 MB | 390,848 B | 214,189 B | -45.2% | | 3 | 154,907 | 66.96 MB | 4.92 MB | 269,414 B | 132,513 B | -50.8% | The lean lane no longer carries a shell command at all; `tool_start` is still its largest remaining type (~30%), but that is the envelope plus each call's identity. Cumulative from the untrimmed lane: -99.75%. Also refreshes CONNECTION.md's ladder, which #870 and #873 had left two generations stale (it still quoted 0.82/0.82/0.47 MB), and records that the measurement now builds each event's real `eventId`.
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 lean feed dropped the two content streams but forwarded every other event verbatim — so a
writestill shipped the whole file it was about to write, and aneditthe text it replaced. On the live lane this was exactly what the history page had already stopped doing (#846). Ausageevent still carried the provider's full report where the client reads a single number out of it.What changed (
remote_host::lean)tool_start/toolcall_start: forwriteandedit, keep only the argument keys a tool row's label is built from (path/file_path/filePath); drop the rest.shellkeeps itscommand(it is the row's label),readkeeps its few bytes, and a tool this build does not know keeps everything — nothing here can tell which of its arguments a future client reads. Both argument shapes are handled (object, and the JSON string the agent has also emitted), preserving the shape and returning the payload borrowed when there is no body to drop.usage: keepcompletion_tokens(plus theoutput_tokensalias the client also reads) and drop the provider's other counters, the credit cost and the stop reason.Both are gated by
lean_events_v1, so an undeclared client is unaffected.Why this is safe
targetFromArgs, which reads onlypath/command-family keys; the file bodies were never rendered.completion_tokensout of a usage event (liveApply.usageOutputTokens), and it passespreferEndTokens: true, so the per-call sum is the fallback for a run with noagent_end. The other counters andcredit_costfeed the desktop footer, whose source is the agent, not this lane (the desktop never subscribes top.{pair}.evt.*— it only publishes).completion_tokenssum = 181,170 =agent_end.usage.output_tokensfor the same run.Measured (three heaviest completed runs, shipping trims, real journals)
Lane composition now: per-tool-call metadata 46–53%, outcomes 15–18%, usage 12–14%, thinking boundaries 16–17%, visible text 2–6%.
Tests
Three new unit tests (
tool_start_drops_the_bodies_only_write_and_edit_carry,tool_start_filters_a_stringified_argument_object,usage_keeps_only_the_counter_a_client_reads) covering: path survives, identity/phase survive, thefile_pathalias, the stringified shape staying a string, shell/read/unknown left byte-identical, a body-less payload returned borrowed, and the usage alias.Falsified: with both trims short-circuited to
Cow::Borrowed, exactly the three new tests fail and the other twelve pass.Desktop backend: 1324 passed / 0 failed;
cargo fmt --checkandcargo clippy --all-targets -D warningsclean. The lean render fixtures (mobile/shot/mock/fixtures/render-lean-*) regenerate to the committed bytes — they were authored to the post-trim shape, so the fixed point holds and no fixture changed.Not done here (measured, needs a decision)
command— 14.4% of the lane. It is the shell row's label, and a live row cannot be fetched back today (toolFromPayloadnever setstoolCallId, andToolRowrequires it plusrunIdto be fetchable). Making it fetchable is small, but until a row is tapped it would show no command at all during the run. Fetching would work if we do it: the assistant entry (with the tool-call arguments) is persisted beforeexecute_toolsruns.{"type":"thinking_start","block_id":"reasoning"}); the cost is the per-event envelope, not the marker. Dropping them would remove the thinking rows.eventIdis always the empty string on every event (27 KB/run, 3.2%) and is read by no client, andsessionId/runId/timestamprepeat per event. That is an envelope-shape change, so it needs its own decision.