You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
save-session.sh fails with error_max_turns on Claude Code 2.1.x (--max-turns 1 broken) #98
save-session.sh silently fails at line 179 with exit 1 on Claude Code 2.1.x. The trap ERR fires and logs FAILED at line 179 (exit 1) but no further detail because set -e pre-empts the error-specific logging at line 183.
Root cause
Claude Code 2.1.x changed turn counting:
Before (1.x):--max-turns 1 = 1 complete response cycle (human prompt → model reply)
After (2.x): turn 1 = prompt delivery, turn 2 = model reply
With --max-turns 1, claude -p now exits 1 before the model can reply:
{
"type": "result",
"subtype": "error_max_turns",
"is_error": true,
"num_turns": 2,
"errors": ["Reached maximum number of turns (1)"]
}
This affects both the main Haiku call (line 176) and the NDC compression call (line 242).
Environment
Claude Code: 2.1.177
Plugin: v0.7.3
OS: macOS 15 (Darwin 25.5.0)
Reproduction
echo"Hello, reply with just OK"> /tmp/test.txt
cd /tmp && env -u CLAUDECODE claude -p \
--model haiku --allowedTools "" --max-turns 1 \
--output-format json \
--mcp-config '{"mcpServers":{}}' --strict-mcp-config \
< /tmp/test.txt
echo"Exit: $?"# → 1
Fix
Change both --max-turns 1 → --max-turns 2 in scripts/save-session.sh:
Line 176 (main Haiku call)
Line 242 (NDC compression call)
# Before
--model haiku --allowedTools "" --max-turns 1 \
# After
--model haiku --allowedTools "" --max-turns 2 \
With --max-turns 2, claude -p exits 0 and subtype: success.
Notes
The is_error: true JSON response still contains full token usage — the model ran successfully, but the CLI exit code was 1
set -e at line 53 causes the trap to fire at the assignment line (HAIKU_JSON=$(...)) before the if [ "$HAIKU_EXIT" -ne 0 ] block can log the stderr — making this hard to diagnose from logs alone
Applied as a local cache patch for now; will be overwritten on plugin update
Fixed in #101 — thank you for the precise diagnosis! 🙏 Your CC-2.x turn-counting writeup (turn 1 = prompt delivery, turn 2 = the reply) plus the clean repro made the root cause unambiguous. --max-turns is now configurable via REMEMBER_MAX_TURNS (default 4, validated to a sane range); the headless summarizer no longer dies before the model replies.
Activity
refactor: single claude call site — bash delegates to pipeline call-h…
refactor: single claude call site — bash delegates to pipeline call-h…
refactor: one claude call site (fixes CC 2.x max-turns #98/#100 + mcp…
fdaviddpt commentedon Jun 18, 2026
Fixed in #101 — thank you for the precise diagnosis! 🙏 Your CC-2.x turn-counting writeup (turn 1 = prompt delivery, turn 2 = the reply) plus the clean repro made the root cause unambiguous.
--max-turnsis now configurable viaREMEMBER_MAX_TURNS(default 4, validated to a sane range); the headless summarizer no longer dies before the model replies.release: 0.8.0 (#106)