fix(provider): replay reasoning_content on thinking-enabled gateway tool calls - #7763
Open
innocarpe wants to merge 1 commit into
Open
fix(provider): replay reasoning_content on thinking-enabled gateway tool calls#7763innocarpe wants to merge 1 commit into
innocarpe wants to merge 1 commit into
Conversation
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
Fix #7748 (and duplicates #7520/#7648/#7564/#7396): an OpenAI-compatible gateway opted into DeepSeek-style thinking via the
thinking=enabledescape hatch (e.g. opencode.ai zen serving DeepSeek models) never replayedreasoning_contenton assistant tool_calls turns, so the DeepSeek-flavored upstream 400'd every turn after the first tool call ("Thereasoning_contentin the thinking mode must be passed back to the API").Changes in
internal/provider/openai/:RequiresToolCallReasoning()now also returns true for generic gateways withthinking=enabled(GLM/Kimi K3 keep their own round-trip policy;thinking=disabledstill opts out)buildRequesttool_calls-turn case widened fromc.deepseekto(c.deepseek || c.RequiresToolCallReasoning())— always emits thereasoning_contentkey (empty included) on tool_calls turns; plain assistant turns still omit itByte-identical for every existing path (DeepSeek official, thinking off, GLM, Kimi K3); the only new wire output is the generic-gateway +
thinking=enabledcase.Issues
Fixes #7748 (Refs #7520 #7648 #7564 #7396)
Verification
go test ./internal/provider/...— pass (4 packages)TestBuildRequestThinkingEnabledGatewayRoundTripsToolCallReasoninggo vet— cleanDocumentation impact
Documentation-impact: none - wire behavior for an opt-in escape hatch; no docs affected.
Cache impact
Cache-impact: medium -
internal/provider/*is a listed cache-sensitive path; the change alters request serialization for thethinking=enabled-on-generic-gateway configuration only (byte-identical for all existing configs), so prompt-cache prefixes are unchanged for existing setups.Cache-guard:
go test ./internal/provider/openai/full suite passes (incl. the existing reasoning-serialization pins); no cache-guard script change needed for an opt-in path.System-prompt-review: N/A