Repository navigation
perf(remote): fetch a lean live shell row's command on tap - #874
Merged
Merged
Conversation
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 live lane still streamed every shell call's command — the largest single thing it had left (~18% of the lane). The history page dropped it long ago and posts the client to
get_tool_call_argswhen a row is opened; this does the same on the live lane, which is what the row's identity is now for.Client (shared package)
A live tool activity now carries
toolCallIdand the run it streamed under — the same pair the persisted projection attaches. Without them a row would be permanently blank once its target is gone:ToolRowonly offers the fetch when it has both.Trim (
remote_host::lean)shell→ keeps nothing but its identity ontool_start.read→ keeps its path (it is the row's label) and two small integers.write/edit→ the path alone, as before.Gated on
lean_events_v1like every other trim, so an undeclared client is unaffected.The price, priced deliberately
The client exempts a bare
grep/diff/testexiting 1 from being shown as a failure, and its predicate reads the command. The agent sends the same verdict asis_soft_failon the outcome — the two predicates agree (same operator set, same program list, same basename/.exe/case handling) and the field has been on the wire since 2026-08-19 — so the exemption normally needs nothing else.What it costs: a row whose outcome predates that field (an agent older than 2026-08-19) now reads as failed instead of completed. Measured on this machine's real history — 20,332 shell results:
exit_code: 1withoutis_soft_failexit_code: 1withis_soft_fail: trueAll 762 are genuine failures (piped/
&&chains, or programs outside the soft-fail set). So the shape this change costs is one the running agent does not produce; the render checks assert it explicitly rather than hiding it.Measured (
scripts/measure/measure-live-lane.py, three heaviest completed runs, real journals, shipping code path)Cumulative from the untrimmed lane: -99.75%. The lane now carries per-call metadata (
tool_start~30%,tool_end~26%), usage counters (~13%), thinking boundaries (~15%) and the visible reply text — no command text at all.Tests
a live shell row keeps the identity to fetch a command the lane dropped(the live counterpart of the history test), anda lean shell row's verdict comes from the agent, not from a command— pinning thatis_soft_fail: trueexempts without a command, thatexit_code: 1without it stays failed (the 762-case reality), and that0/2behave as before. Two existing exact-shape assertions were extended to include the identity (they were the rows that should carry it).tool_start_drops_the_bodies_only_write_and_edit_carry, including the borrowed fast path when there is nothing to drop.lean-render-livesteps already tap every shell row and assert the command appears — so they now verify the live fetch path end to end through the real UI, and the harness answers it from the full-lane fixture the way the agent's own database does. Its counts move from 2 failures / 2 soft to 3 failures / 1 soft, which is the price above; the full-feed control still reads 2 / 2, so the two captures differ by exactly that trade.Falsified both ways: with the trim disabled the lean scenario fails on
three failure rows expected … got 2; with the activity identity removed fromtoActivityItem, exactly the three identity assertions fail.Verification
cargo fmt --check+cargo clippy --all-targets -D warningsclean.--runInBand, the CI configuration);tscandeslintclean.tsc/eslintclean.lean-render-*scenarios exit 0; fixtures regenerate to a fixed point, and their diff is exactly the four shelltool_startevents losingtool_args.scripts/docs/check-docs.py(205 docs) clean.Also
CONNECTION.md's ladder was two generations stale — #870 and #873 changed the lane without updating it, so it still quoted 0.82 / 0.82 / 0.47 MB. Refreshed to the numbers above, with the trim's marginal contribution corrected to -96% to -97% on top of coalescing, and a note that the measurement now builds each event's realeventId(an empty one understates every body by ~96 bytes).Not in this PR
The remaining envelope keys are all read, and the shell row's identity is what the fetch needs — so what is left on the lane is per-call metadata, not waste.