Slash command run during in-flight server-tool (advisor) call orphans tool_result and permanently wedges session (400)

Resolved 💬 2 comments Opened Jun 10, 2026 by elspethsoup Closed Jun 10, 2026

What happened

Running a local slash command (in my case /color) while a server-side tool call is in flight corrupts the session transcript and permanently wedges the session. Every subsequent turn fails with:

API Error: 400 messages.9.content.0: unexpected `tool_use_id` found in
`advisor_tool_result` blocks: srvtoolu_XXXX. Each `advisor_tool_result`
block must have a corresponding `server_tool_use` block before it.

The error recurs on every turn because the broken history is re-sent each time — the session cannot recover on its own.

Root cause

The advisor tool is a server-side tool, so its server_tool_use block and its advisor_tool_result block must be adjacent (use-then-result) within the same assistant message when the request is assembled.

In the session .jsonl, all the relevant blocks share a single assistant message.id, but the slash-command system entries were written between them:

line N    assistant  server_tool_use      (advisor invoked)
line N+1  system      /color ...           <-- slash command run mid-call
line N+2  system      local-command-stdout
line N+3  assistant  advisor_tool_result  (result, now orphaned)

When the request is rebuilt, those interleaved system entries split the single assistant message into two API messages. The advisor_tool_result lands at the start of a new message with no preceding server_tool_use, so the API rejects it with the 400 above.

Repro

  1. Trigger a server-side tool call (e.g. the advisor tool).
  2. While it is still running, run a local slash command (e.g. /color).
  3. Let the tool result come back.
  4. Continue the conversation — every subsequent turn now 400s.

Impact

Session is permanently unusable. The only recovery is rewinding to before the tool call (losing all subsequent work) or hand-editing the .jsonl to remove the interleaved system entries and relink the parent chain.

Suggested fix

Don't allow non-assistant transcript entries to be interleaved between a server_tool_use block and its *_tool_result; either queue local slash commands until the in-flight server-tool call completes, or keep the use/result blocks contiguous when reassembling the request regardless of interleaved system entries.

Environment

  • Claude Code (Opus 4.8)
  • macOS (darwin 25.5.0)

View original on GitHub ↗

This issue has 2 comments on GitHub. Read the full discussion on GitHub ↗