claude-code - 💡(How to fix) Fix --no-session-persistence flag is ignored in 2.1.112 (regression from 2.1.104) [2 comments, 2 participants]

Official PRs (…)
ON THIS PAGE

Recommended Tools

×6

Utilities matched from this issue’s tags and category — try them while you read without losing context.

GitHub issue graph ai analysis

Paste a GitHub issue URL. We fetch that issue, discover linked issues from bodies/comments/timeline, collect linked pull requests, and produce a structured English report.

The report is written in English Markdown for sharing and archival.

Helpful · Quick feedback

Loading…
GitHub stats
anthropics/claude-code#49565Fetched 2026-04-17 08:37:31
View on GitHub
Comments
2
Participants
2
Timeline
9
Reactions
0
Timeline (top)
labeled ×6commented ×2cross-referenced ×1

In Claude Code 2.1.112, the --no-session-persistence flag is effectively a no-op. claude --print --no-session-persistence ... still writes a session .jsonl file (containing a single ai-title entry) to the project's session directory.

This worked correctly in 2.1.104.

Root Cause

Confirmed working in 2.1.104. Confirmed broken in 2.1.112. Versions 2.1.105–2.1.111 not individually tested but reports of orphan behavior date to 2.1.110 (see #49290 for earlier context — that issue misattributed the root cause to internal title generation; the real root cause is this flag regression).

Code Example

# 2.1.112: creates an orphan .jsonl file in the project session dir
cd /path/to/any/project
echo "hello world" | /path/to/2.1.112/claude \
  --print --model haiku --tools '' --output-format text \
  --setting-sources '' --no-session-persistence \
  --system-prompt 'Reply with just "ok"'

# After: check project session dir
ls -la ~/.claude/projects/<encoded-path>/*.jsonl
# A new small file appears, containing only:
# {"type":"ai-title","aiTitle":"Hello world project setup","sessionId":"<uuid>"}
RAW_BUFFERClick to expand / collapse

Summary

In Claude Code 2.1.112, the --no-session-persistence flag is effectively a no-op. claude --print --no-session-persistence ... still writes a session .jsonl file (containing a single ai-title entry) to the project's session directory.

This worked correctly in 2.1.104.

Minimal Reproduction

# 2.1.112: creates an orphan .jsonl file in the project session dir
cd /path/to/any/project
echo "hello world" | /path/to/2.1.112/claude \
  --print --model haiku --tools '' --output-format text \
  --setting-sources '' --no-session-persistence \
  --system-prompt 'Reply with just "ok"'

# After: check project session dir
ls -la ~/.claude/projects/<encoded-path>/*.jsonl
# A new small file appears, containing only:
# {"type":"ai-title","aiTitle":"Hello world project setup","sessionId":"<uuid>"}

Running the identical command with the 2.1.104 binary creates no file.

Regression Window

Confirmed working in 2.1.104. Confirmed broken in 2.1.112. Versions 2.1.105–2.1.111 not individually tested but reports of orphan behavior date to 2.1.110 (see #49290 for earlier context — that issue misattributed the root cause to internal title generation; the real root cause is this flag regression).

Impact

Any integration that invokes claude --print with --no-session-persistence for non-persistent inference — expecting no filesystem side effects — now leaks orphan session files into the user's project directories. These files accumulate over time, clutter session pickers, and contain only title metadata (no conversation data to resume).

Environment

  • CC 2.1.112 (native install, macOS arm64)
  • Confirmed behavior on macOS 15 (Darwin 24.6.0)
  • Not PAI-specific: reproduced with a single direct CLI invocation, no hooks, no wrapper tooling (test was run with all PAI hooks disabled and --setting-sources '' passed to the subprocess)

Suggested Fix

Restore --no-session-persistence to actually prevent session file creation when passed. Currently it appears the flag is parsed but the code path that writes the ai-title entry isn't checking it.

Related

Supersedes #49290 — that issue identified the visible symptom (orphan files from title generation) but misattributed the mechanism. This issue pinpoints the actual regression: the --no-session-persistence flag itself.

extent analysis

TL;DR

The most likely fix is to update the code to properly check the --no-session-persistence flag and prevent session file creation when it is passed.

Guidance

  • Verify that the --no-session-persistence flag is being parsed correctly and its value is accessible in the code path that writes the session file.
  • Check the code that writes the ai-title entry to the session file and ensure it checks the --no-session-persistence flag before writing.
  • Consider adding a test case to ensure the --no-session-persistence flag works as expected in different scenarios.
  • Review the changes made between versions 2.1.104 and 2.1.112 to identify the specific change that caused the regression.

Example

No code snippet is provided as the issue does not contain enough information about the codebase.

Notes

The issue seems to be a regression introduced in version 2.1.110, and the suggested fix is to restore the functionality of the --no-session-persistence flag. However, without access to the codebase, it is difficult to provide a more detailed solution.

Recommendation

Apply a workaround by downgrading to version 2.1.104 until the issue is fixed in a future version, as the --no-session-persistence flag works correctly in that version.

Vote matrix · Quick signals

Works
Did the solution work? Tap to confirm.
Easy Fix
Was it a quick fix?
Time Saver
Did it save you time?
Blocking
Was it severely blocking?
Common Issue
Are others likely hitting this too?
Flaky / Intermittent
Is it intermittent?
Verified / Reproducible
Can you reproduce it reliably?
Loading…

Still need to ship something?

×6

Another batch ranked right after the header list — different links, same matching logic.

Back to top recommendations

TRENDING

claude-code - 💡(How to fix) Fix --no-session-persistence flag is ignored in 2.1.112 (regression from 2.1.104) [2 comments, 2 participants]