Skip to content

Keep deleted sessions searchable, read-only - #59

Merged
devcodes9 merged 2 commits into
mainfrom
feat/keep-expired-sessions
Sep 26, 2026
Merged

devcodes9 merged 2 commits into
mainfrom
feat/keep-expired-sessions

Conversation

@devcodes9

@devcodes9 devcodes9 commented Sep 26, 2026 •

Copy link
Copy Markdown
Owner

Problem

Claude Code deletes transcripts after 30 days by default (cleanupPeriodDays). agsearch dropped its index for a session as soon as the file was gone. So "what did we decide last month?" found nothing, for you or for the agent skill.

Raised on anthropics/claude-code#77523.

What changes

When a transcript disappears, agsearch keeps the text it had indexed:

  • Kept: user and assistant messages, each cut to 2,000 characters.
  • Dropped: tool output (about 69% of the index), thinking, automation runs.
  • For how long: 180 days after the deletion is noticed.
  • Restored transcript: the live file replaces the copy.

How expired sessions behave:

Surface Behavior
TUI row Marked expired, same place as fork
Enter Opens the saved text in the pager instead of resuming
-n Title prefixed with expired
read / preview Shows the saved text and says it can't be resumed
ctrl-y / --no-resume Gives agsearch read <id>

Nothing is written to ~/.claude. The README explains the tradeoff and still leaves cleanupPeriodDays to the user.

Screenshots

Synthetic demo corpus, not real transcripts. The first result's transcript was deleted; the second is its live fork.

TUI: the row is tagged expired, and the preview says it is read only.

TUI row tagged expired

Enter on the expired row: opens the saved copy in the pager, with a note on what it is missing.

Enter opens the saved text

-n (what the agent skill sees): the same tag, in the title position.

-n output with expired tag

Size

On my index, keeping everything would add 44 MB a month. The slim copy is about 7.7 MB for the same sessions, and the 180-day cap bounds it.

Test

  • New tests/test_expired.py (11 tests): searchable after deletion, slimming, automation skipped, read note, row tag, 180-day cutoff, restore, forced rebuild, subagent labels, old layouts dropped.
  • Full suite: 193 tests pass. Review fixes: subagent turns keep their label, kept copies carry a layout version, Enter runs $PAGER through the shell like ctrl-o.
  • End to end in a scratch HOME: index, delete the transcript, then -n, read, _filter, _preview and _copy all behave as above.
  • rank_sessions is untouched, so gold recall@1 is unchanged. -n time on the real index is still ~0.8 s.

Claude Code deletes transcripts after 30 days by default, and agsearch dropped
its index for a session the moment the file went. The session you come back to
for how something was decided is usually older than that, so the one search
that mattered found nothing.

When a transcript disappears, its indexed text is now kept for 180 days. Only
what was said is kept: user and assistant messages, each cut to 2,000
characters. Tool output is two thirds of the index and every search reads the
whole index, so keeping it would slow search down month after month.
Automation runs are not kept at all.

Kept sessions are marked `expired` in the list and in `-n`. They cannot be
resumed, so Enter opens them in the pager instead, `read` says what the copy is
missing, and ctrl-y copies the read command. A transcript that comes back
replaces its copy.
Subagent turns in a kept copy were shown as the main thread, because the
copy did not record that it came from an agent-*.jsonl file. It does now.

Kept copies outlive the cache, so they carry their own layout version and a
copy in an older layout is dropped rather than split wrongly. Fragments left
over from an older CACHE_FMT are not saved at all, since their layout is
unknown.

Enter on an expired row ran $PAGER without a shell, so a pager that is not a
bare binary, or a missing one, raised a traceback. It now goes through the
shell like ctrl-o does. Only the pager string does; the session id and query
are still passed as arguments.
@devcodes9
devcodes9 force-pushed the feat/keep-expired-sessions branch from 39bac6c to 7f327cb Compare September 26, 2026 12:08
@devcodes9
devcodes9 merged commit 64d45b6 into main Sep 26, 2026
6 checks passed
@devcodes9
devcodes9 deleted the feat/keep-expired-sessions branch September 26, 2026 12:09
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant