#1133·ds4

Anthropic API + Qwen: system message sent with a tool_result is dropped by live continuation, then forces a full re-prefill

Author: fleet-agent[bot]Created Sep 26, 2026Updated Sep 29, 2026

Summary

With the Anthropic /v1/messages API and a Qwen3.8 model, a role: "system" message that the client adds in the same request as a tool_result is dropped by the live-continuation fast path. The model never sees it in that turn. On the next request the full render places that system message elsewhere in the prompt, so the live KV no longer matches and the whole prompt is prefilled again.

Claude Code triggers this every time a user sends a message while a tool is running. It delivers that message as a mid-conversation system note ("The user sent a new message while you were working: …") right after the tool result.

Environment

  • ds4 0aaea5a (main as of 2026-09-20), Metal, M1 Ultra 128 GB
  • Model: Qwen3.8-Flash-Next-Q4.gguf, --ctx 65536 --batched-session 6
  • Client: Claude Code 2.1.280, persistent --input-format stream-json session, Anthropic API

Reproduction

  1. Send: Run `sleep 15; date -u` in bash and tell me the output.
  2. About 6 s later, while the tool is running, send: Also: include the word PINEAPPLE in your answer.
  3. After the answer, send: What exact word did I ask you to include earlier? Answer with the word only, or NONE.

Request after the tool result (message tail, captured at the client):

3 user      tool_result: "Sat Sep 26 18:59:18 UTC 2026"
4 system    text: "The user sent a new message while you were working:\nAlso: include the word PINEAPPLE..."

Server log:

anthropic live continuation match=tool-output-ids ids=1 cached=14588 prompt=14624
chat ctx=14588..14624:36 TOOLS prompt start
chat ctx=14588..14624:36 gen=54 TOOLS finish=stop
live kv cache miss live=14678 prompt=14779 common=13041 vision=match reason=token-mismatch
chat ctx=0..14779:14779 TOOLS prompt start      <- full re-prefill, ~30 s
  • Turn 1's answer only reports the date. PINEAPPLE is absent: the continuation added only the 36-token tool output.
  • Turn 2's answer is PINEAPPLE: the full render includes the note.

Expected

  • The continuation path either appends every new message in the request, including a system message after the tool_result, or falls back to a full render when the request contains more than tool outputs.
  • Mid-conversation system messages are rendered where they occur, so the next request still extends the live KV.

Notes

render_qwen_chat_prompt_text collects all system-role messages into the top system block. That is also why per-turn client system notes invalidate the cache even without tools (related: #364). In our setup, rendering mid-list system messages in place, for example as a user-side note, would fix both symptoms.