Repository navigation
Description
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
- Run a Claude Code thread where the last turn fails or is interrupted with an unanswered user message at the tail of the saved Claude transcript (for example, a turn rejected with a 5-hour
usage_limit_reachederror), and let the idle Claude CLI process close (or reopen on resume). - Click Resume on the thread (
turnInput.resume === true, introduced in feat(server): resume stopped provider threads natively #36526). - Observe the Claude Agent SDK protocol frames on the freshly opened
--resumeprocess.
Expected behavior
ClaudeAdapterV2 triggers a single resumed turn on the reopened Claude CLI process. When that turn completes (or fails), the session returns to idle with an empty wakeBuffers and no spurious "Background task completed." continuation queued.
Actual behavior
ClaudeAdapterV2 triggers two back-to-back turns on the same resumed CLI process:
queryRunner.open(apps/server/src/orchestration-v2/Adapters/ClaudeAdapterV2.ts:1591-1596) launches Claude CLI withCLAUDE_CODE_RESUME_INTERRUPTED_TURN=1andCLAUDE_CODE_RESUME_REASON=user_resume. Because the transcript ends on an unanswered user turn, Claude Code CLI immediately auto-starts a resume turn (command_lifecycle: startedwith a CLI-generatedcommand_uuid,resume_reason: "user_resume").startTurn(ClaudeAdapterV2.ts:13644-13650and13981-13987) also unconditionally sendsprompt.offerwith an empty user message ({ role: "user", content: [] },uuid: promptUuid) wheneverRef.get(activeTurn) === context, without checking whether the CLI already started an auto-resume turn. Claude CLI queues this second prompt (command_lifecycle: queued).- Because
ClaudeAdapterV2.ts:13739-13742setspromptEcho: "confirmed"forturnInput.resume, T3 Code settles the active run on Turn 1'sresultand clearsactiveTurntonull. - Immediately afterward (
0mslater), Claude CLI dequeues and runs T3 Code's own emptycontent: []Turn 2 whileactiveTurn === null. handleSdkMessageFrameroutes Turn 2 intobufferWakeMessage(ClaudeAdapterV2.ts:10176-10384), buffers itsassistant+resultframes inwakeBuffers, logsorchestration-v2.claude-wake-turn-detected, and queues a phantom"Background task completed."continuation run.
When combined with a usage limit on the resumed account, that phantom wake stays queued and keeps hasPendingBackgroundWork() permanently true (ClaudeAdapterV2.ts:14441-14454), blocking switching to another Claude account or provider with "The previous provider is still running background agents or commands, and switching would end them. Wait for them to finish, or press Stop, then send the message again." even though no run is active and no Stop button exists.
Impact
Major degradation or frequent failure
Version or commit
Observed on 0.1.10-nightly.20261114.4695; verified unchanged on main @ dd19bce8 (Claude Code CLI 2.1.322).
Environment
Linux x86_64 (t3 serve), Claude Code CLI 2.1.322, claude-opus-5-5.
Logs or stack traces
22:01:03.441Z OUT query.open resume="eeb1834c-..." (with CLAUDE_CODE_RESUME_INTERRUPTED_TURN=1)
22:01:03.444Z IN command_lifecycle command_uuid="f8c700f1-..." state="started" # CLI auto-resume turn
22:01:03.446Z OUT prompt.offer uuid="1bd837e8-..." message={role:"user", content:[]}
22:01:03.457Z IN command_lifecycle command_uuid="1bd837e8-..." state="queued" # queued behind auto-resume
22:01:03.479Z IN system/status status="requesting" user_message_uuids=["142b9059-..."]
22:01:03.640Z IN assistant model="<synthetic>" api_error="usage_limit_reached" resume_reason="user_resume" user_message_uuids=["142b9059-..."]
22:01:03.645Z IN result is_error=true api_error="usage_limit_reached" # closes activeTurn
22:01:03.647Z IN command_lifecycle command_uuid="f8c700f1-..." state="cancelled"
22:01:03.647Z IN command_lifecycle command_uuid="1bd837e8-..." state="started" # T3's own empty prompt starts while activeTurn === null
22:01:03.655Z IN system/init # triggers orchestration-v2.claude-wake-turn-detected -> queues "Background task completed."
22:01:03.657Z IN system/status status="requesting" user_message_uuids=["1bd837e8-..."]
22:01:03.928Z IN assistant model="<synthetic>" api_error="usage_limit_reached" user_message_uuids=["1bd837e8-..."]
22:01:03.929Z IN result is_error=true api_error="usage_limit_reached" # stays in wakeBuffers -> hasPendingBackgroundWork() = true
22:01:03.930Z IN command_lifecycle command_uuid="1bd837e8-..." state="cancelled"
Workaround
Cancel the phantom queued "Background task completed." run via t3_queue(action: "cancel"), which invokes onRunEndedWithoutStarting (retireOfferedWake) and flushes wakeBuffers.
Investigated and reported with Gemini 4 Neon (via Devin ACP in T3 Code).
Happy to open a focused PR with a failing-first unit test in ClaudeAdapterV2.test.ts if maintainers would like one (holding off for now to respect open-PR review capacity).
Activity