--no-session-persistence flag is ignored in 2.1.112 (regression from 2.1.104)
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.
This issue has 4 comments on GitHub. Read the full discussion on GitHub ↗