Skip to content

Stop replaying stale reasoning to the model (dirge-qobx.2) - #841

Merged
yogthos merged 1 commit into
mainfrom
fix/qobx-2-stale-reasoning
Sep 2, 2026
Merged

Stop replaying stale reasoning to the model (dirge-qobx.2)#841
yogthos merged 1 commit into
mainfrom
fix/qobx-2-stale-reasoning

Conversation

@yogthos

@yogthos yogthos commented Sep 2, 2026

Copy link
Copy Markdown
Collaborator

Every provider but OpenAI gets each stored thinking block echoed back inside the assistant turn on every later request (provider_rejects_reasoning_echo), and nothing in the loop ever removed one: prune_tool_outputs only touches tool results, cap_oversized_tool_results only touches string results, and a fold only drops reasoning when it drops the whole message. A long agentic run therefore re-sent the model's entire chain of thought every turn — and invisibly, since the fold's estimator counted a thinking block as zero chars (fixed in #840).

Reasoning from an old turn earns nothing: the model has already acted on it, and the tool results that followed record what came of it. Only the live assistant turn replays its reasoning now — mid-tool-loop that is the turn whose calls produced the trailing results, which is exactly the turn Anthropic requires signed and DeepSeek wants echoed. Earlier turns ship their text and their tool calls without it (dropping a tool_use would orphan its result).

ThinkingReplay::Stale selects that per message at the one production conversion boundary, decided over the whole history the way #833's tool-call pass is — "is this the last assistant message" is not a per-message question.

Anthropic already strips prior-turn thinking server-side and does not bill it, so this is the providers that echo verbatim catching up. The live turn's signature gating is unchanged.

Part of dirge-qobx; #840 is the estimator half.

Every provider but OpenAI gets each stored thinking block echoed back
inside the assistant turn on every later request, and nothing in the
loop ever removed one: prune_tool_outputs only touches tool results,
cap_oversized_tool_results only touches string results, and a fold only
drops reasoning when it drops the whole message. A long agentic run
therefore re-sent the model's whole chain of thought every turn.

Reasoning from an old turn earns nothing — the model already acted on
it and the tool results record what came of it. Only the live assistant
turn (the last one; mid-loop that is the turn whose calls produced the
trailing results) replays its reasoning now. New ThinkingReplay::Stale
selects that per message at the conversion boundary, decided over the
whole history the way #833's tool-call pass is, since 'is this the last
assistant message' is not a per-message question.

Anthropic already strips prior-turn thinking server-side and does not
bill it, so the providers that echo verbatim are the ones this pays
for. The live turn keeps the existing signature gating unchanged.
@yogthos
yogthos force-pushed the fix/qobx-2-stale-reasoning branch from a86e752 to 339540d Compare September 2, 2026 09:05
@yogthos
yogthos merged commit 48e9fc1 into main Sep 2, 2026
15 checks passed
@yogthos
yogthos deleted the fix/qobx-2-stale-reasoning branch September 2, 2026 09:14
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant