On V2, a Claude thread whose turn has finished but still shows Waiting on background task cannot be stopped from that strip. Clicking Stop does nothing: the background shell keeps running and the strip stays up. The server log shows the provider-turn.interrupt effect failing and retrying:
ProviderAdapterProtocolError: Claude provider turn provider-turn:…:ordinal%253A5%3Aattempt%3A1 is not the active turn.
I reproduced it live. I started node -e "setTimeout(…, 120000)" with run_in_background, let the turn settle, and clicked Stop. The provider thread's pendingBackgroundTasks still listed the task 30s later.
Cause#
39c08e1628 ("stop retained background work after a turn settles") let a settled run's Stop through. ProviderTurnControlService.interrupt now calls interruptTurn with requestRuntimeRestart: true when the session still reports background work. Codex handles that case by interrupting its settled turn contexts. Claude's interruptTurn still required the provider turn to be the active one and returned a protocol error otherwise.
Fix#
When no Claude turn is active, requestRuntimeRestart is set, and the live query belongs to the thread's native session, interruptTurn does three things:
- It closes that query. The background shells belong to the CLI process, so they stop with it.
- It clears the thread's wake state.
- It resets its background roster. This is the same process-reset path used when a query is replaced, so it emits an idle
provider_thread.updated with an empty roster.
The next message resumes the session in a new process. Stopping an active turn is unchanged.
Verification#
- New test
ClaudeAdapterV2 background wake turns › stops background work after the turn settled. It uses the wake harness with the recorded local_bash task_started shape: start a background task, settle the turn, then call interruptTurn({ requestRuntimeRestart: true }) for the settled turn. The test asserts that the query closes, the roster empties, hasPendingBackgroundWork is false, and no continuation is offered.
- Without the fix it fails with
Claude provider turn … is not the active turn., the same error the live server logged.
- With the fix it passes.
vp test run src/orchestration-v2/Adapters/ClaudeAdapterV2.test.ts: 119/119 pass.
OrchestratorReplayFixtures, ClaudeReplayFixtures, and ProviderTurnControlService tests filtered to claude/interrupt/stop: 37 pass.
vp exec tsc --noEmit -p . in apps/server: no error TS or warning TS.
vp lint on the touched files: no new findings. The existing no-unused-vars warning on layer is on the base.
knip --workspace apps/server --exports: clean.
- Live re-check on a dev server built from this branch (Claude Sonnet 5): I started a 150s
run_in_background node timer, let the turn settle, and clicked Stop on the Waiting strip. The node process exited, the provider thread went to idle with pendingBackgroundTasks: [], the strip and the sidebar Waiting pill cleared, and no is not the active turn errors were logged. The next message ran normally (AFTER_STOP_OK) on a resumed session.
- Not run: the full server suite.
Model: Claude Opus 5.5 (Claude Code)
🤖 Generated with Claude Code
macroscopeapp[bot](GitHub profile, opens in a new tab) reviewed