Skip to content

fix(Inference.ts): add --no-session-persistence to prevent orphan session files#1042

Open
BrentEubanks wants to merge 1 commit intodanielmiessler:mainfrom
BrentEubanks:fix/inference-session-persistence
Open

fix(Inference.ts): add --no-session-persistence to prevent orphan session files#1042
BrentEubanks wants to merge 1 commit intodanielmiessler:mainfrom
BrentEubanks:fix/inference-session-persistence

Conversation

@BrentEubanks
Copy link
Copy Markdown

Summary

Adds --no-session-persistence flag to the claude --print args in Inference.ts. Without this flag, every hook that calls Inference.ts (SessionAutoName on 2nd+ turn, RatingCapture on responses) creates a new .jsonl session file per invocation, producing dozens of orphan files per conversation that clutter the claude --resume picker.

The Fix

One line added to the args array in Inference.ts (line 85), after --setting-sources:

'--no-session-persistence',  // Prevent orphan .jsonl files (fixes #947)

The --no-session-persistence flag is compatible with --print (which Inference.ts already uses) and simply tells the CLI not to write a session file for transient inference calls.

Testing

  • Ran PAI with this fix applied for several days of active use
  • Confirmed: zero new orphan .jsonl files created after the fix
  • Confirmed: SessionAutoName and RatingCapture continue to function normally
  • Confirmed: claude --resume picker shows only real sessions

Context

Fixes #947. Previous attempts at this fix (#635, #956) were either mis-targeted at older release paths or bundled with unrelated changes. This PR is scoped to the single flag addition only.

…sion files

Hooks calling Inference.ts (SessionAutoName, RatingCapture) spawn
`claude --print`, which creates a new .jsonl session file per invocation.
This produces dozens of orphan files per conversation that clutter the
`claude --resume` picker.

Adding --no-session-persistence prevents these transient inference calls
from writing session files. The flag is compatible with --print which
Inference.ts already uses.

Fixes danielmiessler#947

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
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.

Inference.ts: recursive claude -p calls pollute resume session list

1 participant