BitFun icon indicating copy to clipboard operation
BitFun copied to clipboard

[Bug]: Runtime event journal bloats when tool arguments arrive in small fragments

Open kev1n77 opened this issue 1 week ago • 0 comments

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

  1. 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.

  2. Send a prompt in a fresh session. Have the model fixture start one ExecCommand tool 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);
    
  3. After the SSE content_block_start for the tool, send one content_block_delta of type input_json_delta per byte of args, using the byte as partial_json. The test paused 6 ms every 32 fragments. Hold the stream open before content_block_stop and read <isolated-product-home>/runtime-events/<session-id>.jsonl once the fragments have been recorded. Count records whose event.tool_event.event_type is ParamsPartial.

  4. 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 main at 34bb9e946.
  • Isolated local workspace and loopback Anthropic SSE fixture.

kev1n77 avatar Nov 19 '26 11:11 kev1n77