Stop replaying stale reasoning to the model (dirge-qobx.2) - #841
Merged
Conversation
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
force-pushed
the
fix/qobx-2-stale-reasoning
branch
from
September 2, 2026 09:05
a86e752 to
339540d
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Every provider but OpenAI gets each stored
thinkingblock echoed back inside the assistant turn on every later request (provider_rejects_reasoning_echo), and nothing in the loop ever removed one:prune_tool_outputsonly touches tool results,cap_oversized_tool_resultsonly 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::Staleselects 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.