Repository navigation
Conversation
|
The following comment was made by an LLM, it may be inaccurate: |
|
A data point for this. On a 16.8 GB database, per-turn diff summaries take 2.8 GB across 28,279 turns, and 380 of those turns (1.3%) hold 1.98 GB. The largest is a single turn that deleted 35,080 untracked files under I've applied this on top of dev in my own build: the snapshot tests pass (57 pass, 1 skip), and with the two budget checks removed the new tests fail. |
|
Thanks — this is the first real-world-scale data on the change, and the distribution is the strongest argument for the shape it takes. Two things worth recording from it:
For anyone coming to this later: the reproduction numbers here (16.8 GB database, 28,279 turns, 2.8 GB of patch text, largest row 447 MB) are from an independent build with the change applied on top of |
Issue for this PR
Closes #50089
Type of change
What does this PR do?
A turn stores one patch per changed file, and every patch carries the whole file because
diffFullrenders it withcontext: Number.MAX_SAFE_INTEGER. Nothing bounded the total, so a turn over a large working tree writes the whole working tree into a single message row: the report has one message holding 24,444 file diffs (330 MB), and resuming such a session parses hundreds of MB of JSON.Snapshot.diffFullnow bounds the patch text a single turn keeps with the samelimit(2 MiB) that already decides what is staged into the snapshot at track time:"", the shape binary entries already use, so one oversized file cannot consume the whole allowance;loadis skipped for the remaining batches of 100);file,status,additionsanddeletions, so the changes list, the turn review list, the file counts andopencode exportstay complete — only the display text is dropped.Patch text is display-only (the model request never uses it), so the stored record stays useful while its size is bounded. This applies to the message row written by
session/summary.tsand to the revert path insession/revert.ts, which sharediffFull.How did you verify your code works?
Two new tests in
packages/opencode/test/snapshot/snapshot.test.ts:diffFull drops the patch of a file larger than the tracked file limit— a file that grows past the limit (1.9 MB → 2.6 MB, so it is tracked but its patch is over budget) keeps its additions and status with an empty patch, while a small sibling file keeps its patch;diffFull bounds the patch text stored for one turn— eight 12,000-line files each with one changed line: the file list stays complete and in git order, the entries past the budget are the tail without patch text.Both fail when the two budget checks are removed.
bun test test/snapshot/snapshot.test.ts(57 pass, 1 pre-existing skip),bun test test/session/revert-compact.test.ts test/session/snapshot-tool-race.test.ts test/server/session-diff-missing-patch.test.ts(43 pass),bun run typecheckclean,oxlintclean on both files.Screenshots / recordings
Not a UI change.
Checklist