Skip to content

perf(remote): fetch a lean live shell row's command on tap - #874

Merged
huichen merged 1 commit into
mainfrom
perf/lean-shell-command
Sep 26, 2026
Merged

huichen merged 1 commit into
mainfrom
perf/lean-shell-command

Conversation

@huichen

@huichen huichen commented Sep 26, 2026

Copy link
Copy Markdown
Collaborator

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_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 (shared package)

A live tool activity now carries toolCallId and 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: ToolRow only offers the fetch when it has both.

Trim (remote_host::lean)

  • shell → keeps nothing but its identity on tool_start.
  • read → keeps its path (it is the row's label) and two small integers.
  • write/edit → the path alone, as before.
  • A tool this build does not know → keeps everything.

Gated on lean_events_v1 like every other trim, so an undeclared client is unaffected.

The price, priced deliberately

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 — 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:

shape count
exit_code: 1 without is_soft_fail 762
…of those, a bare soft-fail command (the case the exemption exists for) 0
exit_code: 1 with is_soft_fail: true 1

All 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)

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%

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

  • Shared/mobile: a live shell row keeps the identity to fetch a command the lane dropped (the live counterpart of the history test), and a lean shell row's verdict comes from the agent, not from a command — pinning that is_soft_fail: true exempts without a command, that exit_code: 1 without it stays failed (the 762-case reality), and that 0/2 behave as before. Two existing exact-shape assertions were extended to include the identity (they were the rows that should carry it).
  • Rust: the shell branch of tool_start_drops_the_bodies_only_write_and_edit_carry, including the borrowed fast path when there is nothing to drop.
  • Render harness: the existing lean-render-live steps 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 from toActivityItem, exactly the three identity assertions fail.

Verification

  • Desktop backend 1325 passed / 0 failed; cargo fmt --check + cargo clippy --all-targets -D warnings clean.
  • Mobile 128 suites / 2076 passed, and jest exits on its own (--runInBand, the CI configuration); tsc and eslint clean.
  • Desktop TS 145 files / 1255 passed (it consumes the changed shared package); tsc/eslint clean.
  • All five lean-render-* scenarios exit 0; fixtures regenerate to a fixed point, and their diff is exactly the four shell tool_start events losing tool_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 real eventId (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.

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`.
@huichen
huichen enabled auto-merge (squash) September 26, 2026 09:58
@huichen
huichen merged commit 1657834 into main Sep 26, 2026
12 checks passed
@huichen
huichen deleted the perf/lean-shell-command branch September 26, 2026 10:07
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant