Repository navigation
Description
Summary
When a pi agent edits or writes a file, bb stores the fileChange item with every changes[].diff in item/started, then stores the same diffs again in item/completed. After completion the timeline reads the completed item, so the started copy is dead weight. For large edits that is megabytes per row. I expected the diff to be stored once after the item completes.
Versions and environment
- bb 0.49.0 (desktop app), macOS 27.2 arm64
- provider
pi, pi CLI 1.5.0 (theeditandwritetools) - local data dir
~/.bb
Steps to reproduce
- In a scratch repo:
bb thread spawn --project <project> --provider pi --prompt "Create notes.txt containing the line hello, then use the edit tool to change hello to goodbye." bb thread wait <thread>-
bb thread log <thread> --json --all | jq -c '.[] | select((.type=="item/started" or .type=="item/completed") and .data.item.type=="fileChange") | {seq, type, status: .data.item.status, diffChars: [.data.item.changes[].diff | length]}'
I checked this on existing threads, including 14 file changes written by 0.49.0 in three threads: all 14 started/completed pairs had identical changes. I did not run it on a clean data dir.
Expected vs actual
{"seq":4291,"type":"item/started","status":"pending","diffChars":[336,113]}
{"seq":4292,"type":"item/completed","status":"completed","diffChars":[336,113]}
Expected: once the item has completed, one stored copy of each diff. Actual: item.changes is identical in both rows. Only status differs. The pair above is from an existing thread.
Evidence
Size, measured on one install (37 days, about 2,900 threads, all pi). I took a consistent copy of ~/.bb/bb.db with SQLite .backup, measured it with dbstat, and summed sum(length(data)) by event type and item_kind:
| type | item_kind | rows | size | largest row |
|---|---|---|---|---|
item/started |
fileChange |
9,131 | 0.22 GB | 8.4 MB |
item/completed |
fileChange |
9,149 | 0.22 GB | 8.4 MB |
That is 0.44 GB for one set of diffs, so about 0.22 GB is the second copy. In the two heaviest threads on this install, most of the space is diffs of 2.3 MB and 8.4 MB, each stored twice. Read-only indexed spot checks on single threads found json_extract(data,'$.item.changes') equal between the started and completed rows of the same item.
Code (the same at desktop-v0.49.0 and at current main; neither file changed between them):
- provider-pi builds the
fileChangeshape, witholdText/newTextper edit, attool_execution_start: tag, main. Attool_execution_endit closes the item with that same started shape: tag, main. - The assembler turns each change into a unified diff (
buildFileChanges): tag, main. It emits the full item onitem.openasitem/started(tag, main) and again onitem.closeasitem/completed(tag, main). - Pruning never touches these rows. docs/events-table-pruning.md says: "Completed items and
fileChangeevents remain available to timeline readers."
The started diff is useful while the item is open, for example for a pending approval. A fix could, once item/completed with the same changes exists, drop changes[].diff from the started row or prune the started row. This is a suggestion; I have not checked every reader of item/started.
What you ruled out
- I measured pi only: every thread on this install is a pi thread. The assembler path is shared, so other providers that send diffs at item start may do the same. I have not verified that.
- Related to bb's database grows without limit, and archiving doesn't shrink it #5730 (the database grows without limit), not a duplicate. Turn file-change summary misses shell edits; offer a git-diff source like Changes #6809 (turn file-change summary misses shell edits) is unrelated.
- No issue found for "fileChange diff", "item/started fileChange", "diff stored twice" or "file change diff size" (open and closed).
- Still present on
mainat88cf8f6.
Suggested priority and effort (optional)
Medium: large or generated-file edits add megabytes per edit, twice. No data is lost and there is no user workaround. Effort is probably Low to Medium, depending on which readers use the started row.
Checks
- I reproduced this on the latest release or on
main, or I say above that I could not. - I searched open and closed issues for the same problem.
- If an agent wrote this, the body ends with
> AGENT GENERATEDand links the thread or report. (It ends with the marker. The investigation report is a private local analysis, summarized above.)
AGENT GENERATED
Activity
bb-slop-cop commentedon Nov 13, 2026
🚨 SLOP COP 🚨 ·
new-issue-autopilotthreads,perf, andprovider-pi; no existing classifications were replaced.confirmed-repro.Pi: store a file change's diff once, on completion
Prune duplicated command output and started file-change diffs
Prune duplicated command output and started file-change diffs (get-bb…