Repository navigation
feat(server): idle threads drop old tool output and reasoning to save space - #259
Merged
Merged
Conversation
Thread transfer impact✅ Thread transfer remains within every enforced ceiling.
Other scenariosAll 64 scenario measurements match All 64 scenario measurements
Baseline: Scenario and decoded snapshot size10 historical turns, 5 command tools per turn, 878.9 KiB retained MCP result per historical turn, and a 1.05 MiB retained result in the measured turn.
Updated in place by a trusted workflow. PR artifacts are strictly validated and never executed. |
jayleaton
marked this pull request as ready for review
November 17, 2026 04:02
… space Threads nobody has used for 30 days (setting, 0 turns it off) keep their messages, plans, file changes, runs, checkpoints and handoffs, and lose finished tool output and reasoning. A notice marks where detail was removed. Running, pinned, snoozed, open-PR and side-chat threads are skipped. The sweep logs a dry run at start, runs an hour later, then every six hours. Settings > Maintenance has the setting, a preview and "Trim now". Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
…ayload The estimate read about half the real saving because it ignored the ids each row repeats in its table, indexes and position row. It now reads about 80% (411 MB estimated, 505 MB freed on a seeded copy). Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
… start The server stores when the last trim pass finished. A pass runs when that is 30 or more days ago: while running, within six hours of coming due; after a missed due date, five minutes after the next start. "Trim now" always runs and resets the clock. Settings > Maintenance shows the last and next pass. Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
The upstream sync marks HTML renders, viewed images, sent messages and delegated tasks with inline_work_output. Those are part of what a reader sees, so a trim pass leaves them and their parents in place. Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
jayleaton
force-pushed
the
feat/thread-history-trim-20261117
branch
from
November 17, 2026 05:12
2221dcc to
75a06b5
Compare
Owner
Author
|
Post-merge review, by Randy, at d6db6c5d5. This PR merged at 75a06b5, which adds inline-output retention (
The 41 targeted tests, the changed-file lint and the typechecks passed at the reviewed head. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Problem
The database keeps every tool output and reasoning block for every thread forever. On the bigger machines it is tens of GB, and most of that is detail nobody reads again.
What this does
A thread nobody has used for 30 days keeps what you need to read, find and continue it, and drops the bulky detail.
inline_work_output.Setting: Settings > Maintenance > Thread history (web and desktop), and the same setting on mobile. 0 turns it off; the default is 30 days, max 365. "Trim now" previews the count and size, then asks to confirm.
A trim pass runs once every 30 days. The server stores when the last pass finished (a row in the existing projection metadata table, so it survives restarts and updates; no migration). It checks five minutes after start and every six hours after that, and runs a pass when the last one was 30 or more days ago or none has run. So a machine that was off on the due date trims five minutes after its next start. "Trim now" always runs and resets the clock. Each pass logs a dry run first and trims only threads idle for the setting's days, at a low duty cycle. Space returns through the existing incremental vacuum loop, which now drains a backlog faster; no full
VACUUMruns on a live database.Measurements
Read-only, per machine. Sizes in MB.
auto_vacuumoff, so trimmed space also needs that repair once.Before and after
Seeded dev copy, 738 threads, cutoff lowered to 2 days so there was something to trim.
In the real web app: the trimmed thread reads with its notice, search finds it by message text, and a new turn on a trimmed thread completed through a context handoff (Replay provider).
Captures
Real web client, dev state. Full set: https://gist.github.com/jayleaton/1922d857d2a97a372d16cf5f422b265a
Preview and confirm, then the result:
The toast shot was taken as the dialog faded out, so the section behind it is mid-repaint. Nothing left to trim, and a trimmed thread with its notice expanded:
Schedule line ("Last trimmed · next") in the section:
Tests
ThreadHistoryTrim.test.ts: a trimmed thread still reads, searches and builds resume history, and a second trim is a no-op; excluded threads are untouched; 0 disables it. The schedule test drives a TestClock through two server runs: a pass runs at start when one is due, not again within 30 days, again once due, right after a restart that missed its due date, and a requested trim resets the clock.vp run check:changedpasses withTMPDIR=/private/tmp.Known limits
Claude Fable 5.2, Claude Code
🤖 Generated with Claude Code