[Bug]: Runtime event journal bloats when tool arguments arrive in small fragments
Summary
The in-flight session journal writes a full JSONL record for each streamed tool-argument fragment. In a controlled Desktop run, 33,224 bytes of identical ExecCommand arguments produced 13.65 MB of journal data when sent byte by byte, versus 35.35 KB in a single fragment. The log is removed at turn completion, so this is temporary growth during an active turn.
Expected: keep tool-argument recovery ordered and durable while bounding the journal overhead of small fragments.
This tracks the separate ParamsPartial log growth reported in #3892. That report observed 97,715,880 bytes across 33,227 lines. The controlled run reproduced the per-fragment growth at the same total line count and measured 13,645,695 bytes.
Area
Agent runtime / core, reproduced in the macOS Desktop app.
Reproduction or evidence
-
Start Desktop with an isolated product home and a temporary local workspace. Configure an Anthropic-compatible loopback SSE model using the native workload fixture as the starting point. The fixture uses the real Desktop runtime and needs no provider account.
-
Send a prompt in a fresh session. Have the model fixture start one
ExecCommandtool call. Use the parameters below and an ASCII workspace path so each character can be sent as one byte.const input = { cmd: "printf start > sleep-started; sleep 5; printf 'issue-3892-complete'", workdir: workspace, yield_time_ms: 600000, }; input.cmd += " ".repeat(33_224 - Buffer.byteLength(JSON.stringify(input))); const args = JSON.stringify(input); -
After the SSE
content_block_startfor the tool, send onecontent_block_deltaof typeinput_json_deltaper byte ofargs, using the byte aspartial_json. The test paused 6 ms every 32 fragments. Hold the stream open beforecontent_block_stopand read<isolated-product-home>/runtime-events/<session-id>.jsonlonce the fragments have been recorded. Count records whoseevent.tool_event.event_typeisParamsPartial. -
End the tool block and let the command finish, then return a normal end-of-turn response from the model. Repeat in a fresh session using the same arguments in a single
input_json_delta.
Both cases use the identical 33,224-byte argument JSON. Measurements below are taken with the tool block still open, before the shell command starts.
| Input delivery | ParamsPartial lines | Total lines | Journal bytes |
|---|---|---|---|
| Single fragment | 1 | 4 | 35,347 |
| One-byte fragments | 33,224 | 33,227 | 13,645,695 |
The ParamsPartial records accounted for 13,643,980 bytes in the fragmented run. After the command started, the journal measured 13,680,669 bytes in two samples 1.5 seconds apart. Both real tool calls completed successfully, and their journals were removed at turn completion.
The runtime journal forwards each materialized event to the store. The file store serializes and appends one line per event.
Environment, if relevant
- Local macOS Desktop debug build, Apple M5 arm64, macOS 26.6.2 (25G83).
- The journal and streaming code were checked against upstream
mainat34bb9e946. - Isolated local workspace and loopback Anthropic SSE fixture.