Skip to content

[Bug]: Pi tool output updates store a full snapshot row each (154 rows / 7 MB for one 15s command) #36425

Closed

Description

@koerschner

Claude (anthropic-primary/claude-opus-5-5), assisting Nathan:

Before submitting

  • I searched existing issues and did not find a duplicate.
  • I included enough detail to reproduce or investigate the problem.

Area

apps/server

Steps to reproduce

In a Pi thread, have the agent run this with its bash tool (15 seconds, 300 lines, 213 KB of output):

python3 -c "import time
for i in range(300):
    print(f'line {i:04d} ' + 'x' * 700, flush=True)
    time.sleep(0.05)
"

Then, on a copy of statev2.sqlite:

SELECT json_extract(payload_json, '$.id') AS item,
       count(*) AS rows,
       sum(length(payload_json)) AS bytes,
       max(length(payload_json)) AS largest
FROM orchestration_events
WHERE event_type = 'turn-item.updated'
  AND json_extract(payload_json, '$.type') = 'command_execution'
GROUP BY item
ORDER BY bytes DESC
LIMIT 5;

Expected behavior

A running Pi tool stores a bounded number of rows per item (like Claude and Codex command output), so storage follows the final output size, not how long the output streams.

Actual behavior

That one command item has 154 turn-item.updated rows totalling 7.0 MB, growing to 53 KB each, written over 15.1 seconds (about 10 a second). Its final projection row is 52.6 KB, so the log holds about 130 times the final size. On an ordinary day the same server stores about 1.8 times the final size across all turn items (19,406 rows, 100 MB for 55 MB of final content), so the problem shows up with long, chatty commands and with many of them at once.

What we saw on a real server:

  • A self-hosted, headless t3 serve on Linux. All threads use the Pi provider.
  • Nov 5 to Nov 8, 2026: agents on this server ran about 315,000 bash commands and 95,000 other tool calls in Pi threads (many of them delegated tasks).
  • statev2.sqlite grew to 106 GB (99.05 GiB). The finished turn items from those runs total only about 3 GB.
  • orchestration_events took up to about 132,000 rows an hour, against 1,400 to 5,000 an hour normally. Most were turn-item.updated rows for running tool items, and long commands carried about 50 KB of output in every row.
  • The background prune (every six hours, at 10% duty, keeping at least a day of events) later deleted about 2.2 million superseded rows (about 39 GB). Our database predated incremental auto vacuum, so the file stayed at 106 GB until t3 doctor --fix took the server offline for 30 minutes and printed Done: 99.05 GiB -> 10.06 GiB.

Cause in source:

Related

Possible fixes

  1. Extend the collapse in fix(server): a streamed reply or reasoning block no longer stores every snapshot of its text #36362 to running tool items (command_execution, dynamic_tool and the like while status is running) so only the newest running snapshot row is kept per item.
  2. In the Pi adapter, send bash and powershell output as command_output.delta like Claude and Codex, and store the item only when it starts and ends.

We are happy to send a PR for either if that would help.

Impact

Major degradation or frequent failure

Version or commit

0.1.10, built from main @ 21b0b7a057. The same code is on main @ 36f011dfb7.

Environment

Ubuntu 24.04.5 LTS x86_64, Node 24.21.0, headless t3 serve as a systemd user service, Pi (pi-coding-agent) 1.3.0. We build from a fork that tracks main daily and does not change the Pi adapter or persistence code.

Workaround

None for the write volume. After the prune, t3 doctor --fix (with the server stopped) returns the space on databases created before incremental auto vacuum. Newer databases return it on their own.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions