[Bug]: Stop still kills the Claude CLI and `--resume`s, so every Stop rewrites the full prompt cache (not covered by #10689) #10955
Before submitting#
- I searched existing issues and did not find a duplicate.
- I included enough detail to reproduce or investigate the problem.
Closest existing reports: #10600 (closed by #10689, which only fixed the idle-reaper clock and says "Claude cache invalidation after a genuine restart is unchanged"), #7338 (closed, asked for hard evidence), #8997 (the interrupt-instead-of-close fix, closed unmerged). This is the Stop half of #10600 that the triage there listed as still forcing a --resume.
Area#
apps/server
Steps to reproduce#
- Start a Claude Code thread and let it run a few tool calls so the context is a few tens of thousands of tokens.
- Press Stop while a tool call is running.
- Within the cache lifetime (I waited two minutes) send a follow-up in the same thread.
- Open
~/.claude/projects/<project>/<session-id>.jsonland comparecache_read_input_tokens/cache_creation_input_tokenson the assistant messages before and after the Stop.
Expected behavior#
Stop interrupts the in-flight turn and keeps the CLI process, so the follow-up continues with the same prompt prefix and hits the cache. This is what native Claude Code does on Esc: it appends [Request interrupted by user] and the process stays up.
Actual behavior#
Stop goes through interruptTurn → stopSessionInternal → query.close() in apps/server/src/provider/Layers/ClaudeAdapter.ts (the code comment calls Stop a hard session boundary). The next message --resumes a new process and the whole prompt is re-sent as a cache write.
Per-turn usage from the transcript, deduplicated by message id:
| Time | Event | cache_read | cache_creation |
|---|---|---|---|
| 14:59:33 | last turn before Stop | 66,247 | 1,839 |
| 15:01:34 | Continue from where you left off. meta + <synthetic> reply | 0 | 0 |
| 15:01:44 | first turn after follow-up | 0 | 75,181 |
| 15:02:01 | next turn | 75,181 | 628 |
One Stop rewrote 75k tokens that were cached two minutes earlier. That single turn cost more than the rest of the six-minute session combined, and it scales with thread length. The idle reaper was not involved (two-minute gap), so #10689 does not touch this path.
An extra trigger beyond the git status one in anthropics/claude-code#78720: with the follow-up message the resumed process received a deferred_tools_delta adding claude.ai connector tools (Gmail) and a mcp_instructions_delta appending Linear / Notion / PostHog instruction blocks. Connectors reconnecting late in the fresh process change the system prompt by themselves, so the miss happens even in an untouched repo.
Impact#
Major degradation or frequent failure
Version or commit#
0.0.41-nightly.20260909.1439 (includes #10689)
Environment#
macOS 27.0.0, T3 Code Nightly desktop. Bundled Claude Code 2.1.266 (entrypoint: sdk-ts). Model claude-fable-5-1. Claude subscription, 1-hour prompt cache.
Logs or stack traces#
14:59:33 assistant cache_read=66247 cache_creation=1839
15:01:34 user (isMeta) "Continue from where you left off."
15:01:34 assistant model=<synthetic> "No response requested."
15:01:38 user "fetch latest from gh, ..."
15:01:38 attachment deferred_tools_delta addedNames=[mcp__claude_ai_Gmail__..., ...]
15:01:38 attachment mcp_instructions_delta addedNames=["claude.ai Linear","claude.ai Notion","claude.ai PostHog"]
15:01:44 assistant cache_read=0 cache_creation=75181
15:02:01 assistant cache_read=75181 cache_creation=628
Full transcript lines available on request.
Workaround#
Don't press Stop. Disabling cloud connectors in Claude Code settings (disableClaudeAiConnectors: true) removes one source of prompt mutation but not the restart itself.
juliusmarminge added labelsbug
juliusmarminge added labelsaccepted
juliusmarminge added labelsvia-triage
Tested main b5a226e49c in the real web dev client on Linux, Claude Code 2.1.303, Claude Fable 5.1, with isolated seeded state and a new thread. Read files to build ~100k context, pressed Stop during
sleep 90, then sent a follow-up within one minute. Repeated with a new untracked file added between Stop and the follow-up.Stop did terminate the CLI; the next process used
--resume. The reported full cache rewrite did not reproduce. Deduplicated assistant-message usage from the native JSONL:Attempt Last call before Stop: read / creation First real call after Stop: read / creation Repository unchanged 67,984 / 31,796 99,780 / 304 Untracked file added after Stop 100,168 / 605 100,773 / 287 The synthetic resume reply had zero usage in both attempts. This environment does not have your Claude.ai Gmail/Linear/Notion/PostHog connector setup; macOS desktop and bundled CLI 2.1.266 were not tested.
Does the full rewrite still occur on a current build? Please provide the current T3/Claude versions and a sanitized JSONL excerpt spanning the last pre-Stop response, resume, connector deltas, and first post-Stop response (including message IDs and usage). If possible, compare the same Stop/follow-up with Claude.ai connectors disabled. That will distinguish the remaining connector/prompt change from the process restart, which still occurs here.
No open duplicate or process-retention fix PR found. The earlier retention attempt #8997 is closed unmerged; open Stop-timeout fixes retain process closure.
juliusmarminge added labelsneeds more info
Closing: no reply in 7 days after we asked for more information. Comment with the missing details and we will reopen.
Sign in to join this conversation.
Triage#
Confirmed. This is the Stop half of #10600, and #10689 does not cover it.
#10689 only fixed the idle-reaper clock (
lastSeenAtvs sessionupdatedAt). Its PR text says Claude cache invalidation after a genuine restart is unchanged. Two minutes after Stop is well inside the 30-minute idle window, so the reaper was not involved.What current
maindoes#Stop (
apps/server/src/provider/Layers/ClaudeAdapter.ts):interruptTurncallsstopSessionInternal, whichquery.close()s the CLI. The comment calls Stop a hard session boundary:interrupt()can ack while resumed background tasks keep the process alive (the #5891 runaway-fleet case).interruptTurn settles live tasks and closes the provider session.Follow-up (
ProviderService.sendTurn→recoverSessionForThread):hasSessionis false, so the next message starts a new process with the persistedresumeCursor.startSessionpassesresume: existingResumeSessionId(SDK--resume).That matches the transcript: last turn
cache_read=66,247; first turn after Stopcache_read=0/cache_creation=75,181; next turn reads the new 75k prefix. Native Claude Code keeps the process up on Esc and appends[Request interrupted by user].The
deferred_tools_delta/mcp_instructions_deltaon the resumed process is a second prefix mutation on top of thegit statuscase in claude-code#78720. Disabling connectors removes that mutation but not the restart. Cache invalidation after restart is Claude CLI behavior; T3’s Stop teardown is what forces the restart.What this is not#
SendMessageresume guard).Related#
interrupt(), leftover SDKresultcompleting the next turn, and pending approvals / AskUserQuestion left open.--resumepaths still exist: idle reaper, explicit session stop, server update /stopAll, effort / session replacement. Out of scope here.Next step#
T3-actionable: keep the Claude CLI alive across Stop.
Revisit the #8997 approach (
stopTask+query.interrupt(), complete the local turn, keep the process;close()only if live tasks remain) and address those review findings.thread.session.stopand the idle reaper should still tear the process down.Do not reopen #8997 as-is. The #5891 close-on-Stop behavior has to stay as the fallback when cooperative interrupt cannot settle live work.
Workaround remains: don’t press Stop.
disableClaudeAiConnectors: trueonly removes one prefix-mutation source.Severity: major for long Claude threads (full prefix rewrite per Stop; scales with context). Not a crash, and not an established subscription-quota percentage.