Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 10 additions & 1 deletion ds4_server.c
Original file line number Diff line number Diff line change
Expand Up @@ -10604,7 +10604,16 @@ static bool should_remember_thinking_checkpoint(const request *r,
const thinking_state *thinking,
const char *finish,
ds4_chat_format format) {
if (!r || r->kind != REQ_CHAT || r->has_tools) return false;
if (!r || r->kind != REQ_CHAT) return false;
/* Tools offered but never used must not cost a full re-prefill. The call
* site already excludes turns that sampled tool calls (!parsed_calls.len),
* so this guard only covers "the request carried tool definitions". For
* Qwen the reuse path additionally proves an exact token prefix of the
* remembered visible tokens before continuing, so a tools-present prompt
* that renders differently fails closed into ordinary token/text/disk
* matching. Agentic clients (OpenCode) pass tools on every turn and answer
* with text most turns; without this the whole prompt is re-prefilled. */
if (r->has_tools && format != DS4_CHAT_FORMAT_QWEN36) return false;
if (r->prompt_preserves_reasoning) return false;
/* Qwen's no-thinking generation prefix still contains a trusted
* <think>...</think> wrapper that the next canonical history omits. */
Expand Down