fix(replay): give every assistant turn a thinking block before the upstream call - #111
Open
chrisnestrud wants to merge 1 commit into
Open
chrisnestrud wants to merge 1 commit into
chrisnestrud wants to merge 1 commit into
Conversation
…stream call DeepSeek rejects a thinking-enabled conversation whose assistant turn carries no thinking block, with "The content[].thinking in the thinking mode must be passed back to the API". That applies to text-only assistant turns as well as tool-call turns. prependCachedThinking skipped every assistant message without a tool_use block, so a conversation whose earlier assistant turn was plain text reached the provider bare and was rejected. Verified against the provider with the captured failing request: the captured body returns 400, and the same body returns 200 once the plain assistant message gains a thinking block (empty or filled), while dropping that message also returns 200. The adapter path now applies the same rule the plugin already applies on its own path: tool-call cache, then assistant-text cache, then the empty boundary block. Refs: ZhiYi-R#102 ZhiYi-R#63
This was referenced Sep 16, 2026
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.
Summary
Fixes a replay gap that makes every later request in a session fail once that
session contains a text-only assistant turn.
turns that contain
tool_use.then the empty boundary block.
visible in the log instead of silent.
candidate_routing_test.go, whose expectation that a text-onlyassistant turn stays bare encoded the defect, and add coverage for the
text-only turn, an existing thinking block, and tool-call cache preference.
Fixes #110
Root cause
prependCachedThinkingskipped assistant messages without atool_useblock.The provider requires a thinking block on every assistant turn while thinking
is enabled; the plugin path already handled any assistant turn, the adapter
path did not.
Validation
Replaying the captured failing request against the provider: as-is returns 400,
adding an empty thinking block to the plain assistant turn returns 200, and
without that block it returns 400 again. Running this build on a live proxy:
zero
content[].thinking400s across 185 streamed requests where the failurewas previously constant, and a four-turn tool-call probe that previously died
completes.
Note: this branch is based on
main, independently of #103; the two fixes donot interact.