Skip to content

[Bug]: Claude /compact is killed by the 2-minute idle session release (#41174) and can leave the thread unresumable #41474

Closed as not planned

Description

@Fussely

Before submitting

  • I searched existing issues and did not find a duplicate.
  • I included enough detail to reproduce or investigate the problem.

Area

apps/server

Steps to reproduce

  1. On nightly 0.1.12-nightly.20261123.5138 (Windows desktop app), open a Claude (claudeAgent) thread with a large context, so that compacting takes longer than 2 minutes or close to it. I saw this at about 130k and about 420k tokens.
  2. Send /compact.
  3. Wait.

Expected behavior

The session stays alive until the compaction finishes, and the thread continues from the compacted context.

Actual behavior

About 120 s after /compact is sent, ProviderSessionManager.releaseIfStillIdle closes the Claude session while the compaction is still running. The compaction is lost or never recorded. It looks like the 2-minute idle release from #41174 doesn't count a running /compact as activity, even though Claude Code keeps sending system/status: compacting every 30 s.

This build is the first with #41174. On the previous build, 20261123.5124, the same thread was released after exactly 30 minutes idle (07:24:47 → 07:54:47 UTC). On 5138, idle releases happen at 2 minutes. Before the update, every manual compaction on this machine finished in 32 to 105 s, so none of them reached a 2-minute limit.

All times below are UTC.

Case 1: about 420k tokens of context

  • 13:05:11.808: /compact sent. system/status: compacting at 13:05:11, 13:05:41 and 13:06:11.
  • 13:07:11.853: ProviderSessionManager.releaseIfStillIdle → closeScopeWithin → ClaudeAdapterV2.interruptTurn → query.close (13:07:11.860). That is 120.0 s after /compact.
  • The turn fails with "The provider event stream closed unexpectedly. Retry the turn; if it keeps failing, check the provider and server logs."
  • No compact_boundary was written to the session transcript. The next turn started with 423,790 input tokens, so the compaction was lost. The thread itself kept working.

Case 2: about 131k tokens of context, which leaves the thread unusable

  • 11:36:59.019: /compact sent. system/status: compacting at 11:36:59, 11:37:29 and 11:37:59.
  • 11:37:59.702: Claude Code writes the compact_boundary to the session transcript (durationMs 60664, with a preserved segment). T3's provider event log records no compact_boundary or result frame for it.
  • 11:38:59.060: query.close, 120.0 s after /compact. The provider turn is recorded as interrupted. (The server trace for this minute has already rotated out, so I can't confirm it was releaseIfStillIdle here as well, but the timing is the same.)
  • 11:39:55: I sent /compact again. This one completed at 11:40:40 (45 s, small context).
  • 11:40:57: T3 sets the provider thread's nativeConversationHeadRef to 2a9a1da3-…. That is the final assistant message of the second-to-last completed turn (10:25:55). The last completed turn, a7a4f28f-… (11:36:18), was skipped, even though it is in the first compaction's preserved segment. 2a9a1da3-… is not on the chain Claude Code loads after either boundary.
  • From then on, every send fails within about 1 s with "The provider could not start this turn. Retry the turn; if it keeps failing, check the provider setup and server logs." This happened for 6 runs in a row, and the thread could not be recovered from the UI.

Related:

Impact

Major degradation or frequent failure

Version or commit

0.1.12-nightly.20261123.5138 (desktop). Not seen on 0.1.12-nightly.20261123.5124, which still released idle sessions after 30 minutes.

Environment

Windows 11, T3 Code desktop app, Claude Code CLI 2.1.330, claude-opus-5-5 (effort high, 1M context window).

Logs or stack traces

# Case 1: provider event log (stream_event frames omitted)
13:05:11.808Z outgoing prompt.offer            /compact
13:05:11.852Z incoming system/status           compacting
13:05:41.880Z incoming system/status           compacting
13:06:11.880Z incoming system/status           compacting
13:07:11.860Z outgoing query.close             # 120.0 s after /compact

# Case 1: server trace at the close
13:07:11.853Z ProviderSessionManager.releaseIfStillIdle
13:07:11.858Z   ProviderSessionManager.closeScopeWithin
13:07:11.863Z ClaudeAdapterV2.interruptTurn    # parent: RunExecutionService.startRootRun of the /compact run (13:05:11.727Z)
13:07:11.866Z RunExecutionService.interruptLostToolCalls

# Case 2: provider event log
11:36:59.019Z outgoing prompt.offer            /compact
11:36:59.043Z incoming system/status           compacting
11:37:29.050Z incoming system/status           compacting
11:37:59.051Z incoming system/status           compacting
# (transcript: compact_boundary written at 11:37:59.702Z, never seen by T3)
11:38:59.060Z outgoing query.close             # 120.0 s after /compact

# Case 2: every later turn
ProviderAdapterTurnStartError (driver claudeAgent)
  cause: ProviderAdapterProtocolError: Claude provider query ended before the turn could start.
    cause: ClaudeAgentSdkQueryRunnerError: Claude Code returned an error result:
      No message found with message.uuid of: 2a9a1da3-e21d-43c6-bd34-e32f8147565a

Workaround

Don't /compact long Claude threads on this build. If a compaction is cut off as in case 1, the thread stays usable at its old size. If a thread ends up as in case 2, start a new thread and carry the context over by hand.

Activity

  1. juliusmarminge commented on Nov 23, 2026

    @juliusmarminge
    Member

    I tried to reproduce this on the current build and could not.

    Commit d1a6c35 (origin/main). A live Claude /compact could not be run: no VM has first-party Claude sign-in. Instead I reproduced it against the real ProviderSessionManager in apps/server/src/orchestration-v2/ProviderSessionManager.test.ts. The fake runtime gained compactThread. The new test 'keeps a session alive past idle while /compact runs' opens a session with idleTimeoutMs 1000, starts a /compact turn through runtime.compactThread with no turn.terminal, advances TestClock 2 s and asserts manager.isLive. It fails on main ('expected false to be true'): the session is released while the compaction is still running. As a control, the same test calling runtime.startTurn passes. Command, from apps/server: vp test run src/orchestration-v2/ProviderSessionManager.test.ts -t "while /compact". This matches the reporter's trace, where releaseIfStillIdle closes the session 120.0 s after /compact (the 2-minute native-resume idle timeout from #41174). The Claude adapter emits activity for only the first 'system/status: compacting' while a compaction runs (ClaudeAdapterV2.ts ~11526), so later status frames do not push the timer back.

    Closing as not planned. If it still happens for you, reply with the exact steps and the version you are on and it will be looked at again.

  2. Fussely commented on Nov 23, 2026

    @Fussely
    Author

    Thanks for looking into this! I think the closing verdict may be a mix-up: the comment describes reproducing the bug rather than failing to. The new test "keeps a session alive past idle while /compact runs" fails on main (the session is released while the compaction is still running), while the startTurn control passes. It also points to the cause: the Claude adapter only emits activity for the first system/status: compacting frame (ClaudeAdapterV2.ts around line 11526), so later status frames don't push the idle timer back.

    It still happens on 0.1.12-nightly.20261123.5138 with the steps in the report: a /compact on a Claude thread large enough that compaction takes over 2 minutes. Could this be reopened?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions