[BUG] Desktop (macOS, Code tab): after archive_session "self" returns, the CLI makes one more model call before the kill; a tool call in it is left as a dangling "Archiving session" card

Status Open
Reported on v2.1.286
Maintainer reply None cached
Activity 0 comments · opened Oct 4, 2026

Preflight Checklist

  • [x] I have searched existing issues and this hasn't been reported yet (closest: #90712 and #94641 are about sessions that keep running or hang; this one is about the extra model call that happens before the kill)
  • [x] This is a single bug report
  • [x] I am using the latest version of Claude Code

What's Wrong?

In the desktop app (Code tab), when a session calls mcp__ccd_session_mgmt__archive_session with session_id: "self", the tool result comes back ("Archiving this session … The conversation will end."), but the CLI's agentic loop still sends one more API request before the app kills the process, about 2 s later.

What that extra call produces decides what is left behind:

  • If the model answers with text, the app shows the text under the "Archived session" card (harmless, but it is a full extra request against the cached context).
  • If the model issues a tool call (in my case it called archive_session self a second time), the process is killed before that call gets a result. The transcript ends on a dangling tool_use, and the UI shows the finished "Archived session" card followed by an "Archiving session" card whose timer keeps running. No process is behind it (pgrep finds nothing); the card never resolves, and after an unarchive it is still shown in that state.

Measured in two sessions on 2026-10-04:

| | Session A | Session B |
|---|---|---|
| tool result | 07:04:06.9Z | 07:35:46.9Z |
| extra API request | 07:04:07.8Z, answered with one word | 07:35:48.9Z, a second archive_session self |
| tokens of that request | 223,556 cache-read · 6 output | 145,290 cache-read · 115 output |
| then | Stop hooks start and all four die in 181 ms with exit 1 | process killed before the tool result; transcript ends on the tool_use |

The Stop hooks of that turn are killed mid-run (four hook_non_blocking_error attachments, exit 1, identical 181 ms), while the SessionEnd hook still runs.

What Should Happen?

The tool's own description says "the conversation ends after this tool result". The loop should stop at that result: no further API request, and the archive tool card should resolve instead of staying in the in-progress state. If a last request is intended (so the model can say goodbye), a tool call made in it should at least be rejected or resolved rather than left dangling.

Error Messages/Logs

Transcript tail of session B (~/.claude/projects/<cwd>/<session>.jsonl, abbreviated):

assistant  tool_use  mcp__ccd_session_mgmt__archive_session {"session_id":"self", ...}   07:35:46.4Z
user       tool_result "Archiving this session (...). Side sessions ... The conversation will end."  07:35:46.859Z
assistant  tool_use  mcp__ccd_session_mgmt__archive_session {"session_id":"self", ...}   07:35:48.914Z   <- never answered; file ends here

Session A, same spot:

user       tool_result "Archiving this session (...). The conversation will end."   07:04:06.889Z
assistant  text "Archived."  (stop_reason end_turn)                                   07:04:07.845Z
attachment hook_non_blocking_error Stop exocortex-reply-shape        exitCode 1  durationMs 181   07:04:08.924Z
attachment hook_non_blocking_error Stop <three more Stop hooks>      exitCode 1  durationMs 181

Steps to Reproduce

  1. Desktop app, Code tab, permission mode auto (so the call needs no approval click).
  2. In any session, type archive so the model calls archive_session with session_id: "self".
  3. Open the session's transcript .jsonl after it ends: one more assistant message follows the archive tool result.
  4. For the dangling card: it happens when the model's extra message is a tool call (observed as a second archive_session self); the UI then shows "Archived session" + "Archiving session" with a live timer.

Claude Model

claude-opus-5-5

Is this a regression?

Not sure

Last Working Version

_No response_

Claude Code Version

2.1.286 (desktop app, Code tab)

Platform

macOS, Claude desktop app (Code tab)

Operating System

macOS 26 (Darwin 25.6.0), Apple Silicon

Terminal/Shell

Claude desktop app (Code tab); shell zsh

Additional Information

  • Both sessions ran with user-defined Stop and SessionEnd hooks; the hooks are not the cause (they are killed, not bouncing), but the kill lands while they run, which may matter for people whose Stop hooks do work.
  • Cost side: the extra request re-reads the whole cached context, roughly 1–2 % of each session's total tokens here.
  • Related: #90712 (archived session keeps running), #94641 (self hangs in scheduled runs).

View original on GitHub ↗