What happened
When an agent calls t3_thread_organize with action: "archive" and no threadId (its own thread) during its turn, the archive succeeds. The run then ends as failed with "The provider event stream closed unexpectedly", even though every earlier step in that turn succeeded. Expected: either the archive waits until the turn ends, or self-archive is refused with a clear error. Reproduces 4 out of 4 runs, desktop app, macOS arm64.
Diagnosis
thread.archive has no active-run guard, and it tears down the caller's live provider session.
t3_thread_organize (apps/server/src/mcp/toolkits/thread/handlers.ts:275) dispatches thread.archive for the caller's thread. assertLiveCaller (mcp/threadAccess.ts:40) requires the caller to have an active run, so a self-archive always targets a thread in the middle of a turn.
- The decider only rejects threads that are already archived (
orchestration-v2/Orchestrator.ts:2264). Archive cancels queued runs only (:2964) and leaves the running run alone. It then detaches every provider session with detail: "Thread archived." and revokeMcpCredential: true (:3033-3106). The comment at :3026 says this is safe for settle because settle rejects active runs. Archive has no such check.
- For a single-thread session (Claude here),
ProviderSessionManager.detach releases the entry (:1871). releaseEntry then calls failSubscribers (:512), which pushes ProviderAdapterEventStreamError("Thread archived.") into the run's event stream.
RunExecutionService (:1267-1307) still sees the run as running, so it writes a failed terminal. ProviderFailure.ts:47 maps that to the generic "stream closed unexpectedly" text, and "Thread archived." is never shown.
For comparison: settle rejects active runs (Orchestrator.ts:2352), delete cancels them before detaching (ThreadDeletion.ts:70), and the web UI disables Archive while a thread is running (threadActionMenu.logic.ts:51). That UI code's comment says the server rejects the action, which v2 no longer does. Codex and OpenCode2 sessions take the interruptTurn path in detach, so they would likely end as interrupted instead (not tested). On main (e8545b2), Orchestrator.ts and the MCP toolkit are unchanged since this tag, and releaseEntry still fails subscribers.
Possible fixes: reject thread.archive while a run is active, as settle does, so the agent gets a clear error. Or defer a self-archive until the turn ends.
Steps to reproduce
- In the desktop app, start a thread on Claude.
- Ask the agent to call
t3_thread_organize with action: "archive" and no threadId, then reply "done".
- The thread is archived within about 10 ms of the tool call starting, and the run fails with "The provider event stream closed unexpectedly". The tool call item stays
running.
Version
0.0.46-nightly.20261003.2623 (fed41fa)
Environment
macOS 27.0 (26A428) arm64, Node v26.8.2, Claude Code 2.1.288, desktop app with local server
Evidence
# statev2.sqlite projections, 2026-10-03 (UTC). These are the only failed runs in the database.
thread tool started archived_at run failed last tool call
cd17f2c6 09:29:55.154 09:29:55.165 09:29:55.172 t3_thread_organize {"action":"archive"} [running]
feb9e7ee 09:35:33.715 09:35:33.722 09:35:33.729 same
5f2febba 09:55:35.674 09:55:35.683 09:55:35.689 same
3d61eeab 09:55:36.278 09:55:36.289 09:55:36.294 same
94e4b217 09:58:11.197 09:58:11.200 09:58:11.204 same
67d809c6 09:58:17.022 09:58:17.026 09:58:17.029 same
error turn item: {"class":"unknown","message":"The provider event stream closed unexpectedly. Retry the turn; if it keeps failing, check the provider and server logs.","code":null,"retryable":null}
Related issues
#14203 (closed) asked for archive to stop the provider session, which v2 now does, but nothing handles a running turn. #14907 (open PR) covers archived threads starting work after setup, which is a different path. I found no existing issue for archiving a thread with a running turn.
Fix applied or workaround
Nothing changed on the machine. Workaround: archive from another thread, or manually after the turn ends. Settle is not a workaround from inside the turn, because it rejects active runs.
Filed by
Claude Code 2.1.288 (claude-opus-5-5) via t3 triage
What happened
When an agent calls
t3_thread_organizewithaction: "archive"and nothreadId(its own thread) during its turn, the archive succeeds. The run then ends as failed with "The provider event stream closed unexpectedly", even though every earlier step in that turn succeeded. Expected: either the archive waits until the turn ends, or self-archive is refused with a clear error. Reproduces 4 out of 4 runs, desktop app, macOS arm64.Diagnosis
thread.archivehas no active-run guard, and it tears down the caller's live provider session.t3_thread_organize(apps/server/src/mcp/toolkits/thread/handlers.ts:275) dispatchesthread.archivefor the caller's thread.assertLiveCaller(mcp/threadAccess.ts:40) requires the caller to have an active run, so a self-archive always targets a thread in the middle of a turn.orchestration-v2/Orchestrator.ts:2264). Archive cancelsqueuedruns only (:2964) and leaves therunningrun alone. It then detaches every provider session withdetail: "Thread archived."andrevokeMcpCredential: true(:3033-3106). The comment at:3026says this is safe for settle because settle rejects active runs. Archive has no such check.ProviderSessionManager.detachreleases the entry (:1871).releaseEntrythen callsfailSubscribers(:512), which pushesProviderAdapterEventStreamError("Thread archived.")into the run's event stream.RunExecutionService(:1267-1307) still sees the run asrunning, so it writes a failed terminal.ProviderFailure.ts:47maps that to the generic "stream closed unexpectedly" text, and "Thread archived." is never shown.For comparison: settle rejects active runs (
Orchestrator.ts:2352), delete cancels them before detaching (ThreadDeletion.ts:70), and the web UI disables Archive while a thread is running (threadActionMenu.logic.ts:51). That UI code's comment says the server rejects the action, which v2 no longer does. Codex and OpenCode2 sessions take theinterruptTurnpath indetach, so they would likely end as interrupted instead (not tested). Onmain(e8545b2),Orchestrator.tsand the MCP toolkit are unchanged since this tag, andreleaseEntrystill fails subscribers.Possible fixes: reject
thread.archivewhile a run is active, as settle does, so the agent gets a clear error. Or defer a self-archive until the turn ends.Steps to reproduce
t3_thread_organizewithaction: "archive"and nothreadId, then reply "done".running.Version
0.0.46-nightly.20261003.2623 (fed41fa)
Environment
macOS 27.0 (26A428) arm64, Node v26.8.2, Claude Code 2.1.288, desktop app with local server
Evidence
Related issues
#14203 (closed) asked for archive to stop the provider session, which v2 now does, but nothing handles a running turn. #14907 (open PR) covers archived threads starting work after setup, which is a different path. I found no existing issue for archiving a thread with a running turn.
Fix applied or workaround
Nothing changed on the machine. Workaround: archive from another thread, or manually after the turn ends. Settle is not a workaround from inside the turn, because it rejects active runs.
Filed by
Claude Code 2.1.288 (claude-opus-5-5) via t3 triage