Summary
Inference.ts runs claude -p for sentiment analysis, failure description generation, and other inference tasks. Each invocation creates a persisted session that appears in claude --resume, polluting the resume picker with hundreds of short, meaningless inference sessions.
Over normal usage, this generates 224+ ghost sessions that crowd out real conversations in the resume list.
Environment
- PAI v4.0.0, Algorithm v3.5.0
- Claude Code (Windows/MSYS2)
- Inference callers:
RatingCapture.hook.ts (UserPromptSubmit), FailureCapture.ts
Root Cause
Inference.ts:99 builds the claude -p command without --no-session-persistence:
const cmd = `cat "${pf}" | claude -p --model ${config.model} --output-format text --setting-sources '' --system-prompt "$(cat "${sf}")" > "${of}" 2> "${ef}"`;
The existing reliability measures (env stripping per #931, background+file approach per #26190, --setting-sources '') prevent hangs and recursive hook firing — but sessions are still written to disk and indexed in the resume picker.
Fix
Add --no-session-persistence to the claude -p command in Inference.ts:
const cmd = `cat "${pf}" | claude -p --no-session-persistence --model ${config.model} --output-format text --setting-sources '' --system-prompt "$(cat "${sf}")" > "${of}" 2> "${ef}"`;
One-line change. All callers (RatingCapture, FailureCapture, any future inference users) are fixed since they all go through inference().
Cleanup
Existing polluted sessions can be identified by grepping session JSONL files for inference markers:
grep -rl "CLASSIFY THIS MESSAGE FOR SENTIMENT\|Generate the 8-word description" ~/.claude/projects/*/*.jsonl
And safely deleted — they contain only single-turn classification prompts with no user value.
Verification
After the fix:
- Trigger a
UserPromptSubmit hook (send any message in Claude Code)
- Check
ls ~/.claude/projects/C--Users-rohan/*.jsonl | wc -l — count should not increase
claude --resume should only show real conversations
Notes
Summary
Inference.tsrunsclaude -pfor sentiment analysis, failure description generation, and other inference tasks. Each invocation creates a persisted session that appears inclaude --resume, polluting the resume picker with hundreds of short, meaningless inference sessions.Over normal usage, this generates 224+ ghost sessions that crowd out real conversations in the resume list.
Environment
RatingCapture.hook.ts(UserPromptSubmit),FailureCapture.tsRoot Cause
Inference.ts:99builds theclaude -pcommand without--no-session-persistence:The existing reliability measures (env stripping per #931, background+file approach per #26190,
--setting-sources '') prevent hangs and recursive hook firing — but sessions are still written to disk and indexed in the resume picker.Fix
Add
--no-session-persistenceto theclaude -pcommand inInference.ts:One-line change. All callers (RatingCapture, FailureCapture, any future inference users) are fixed since they all go through
inference().Cleanup
Existing polluted sessions can be identified by grepping session JSONL files for inference markers:
And safely deleted — they contain only single-turn classification prompts with no user value.
Verification
After the fix:
UserPromptSubmithook (send any message in Claude Code)ls ~/.claude/projects/C--Users-rohan/*.jsonl | wc -l— count should not increaseclaude --resumeshould only show real conversationsNotes
--no-session-persistenceflag is documented as working only with--print, which is exactly how Inference.ts uses it