Repository navigation
gateway: a Chat turn's thinking is read in every spelling the client … - #1075
Open
TryWorld2026 wants to merge 1 commit into
Open
TryWorld2026 wants to merge 1 commit into
TryWorld2026 wants to merge 1 commit into
Conversation
…sends it back in A client sends the previous assistant turn's thinking back in reasoning_content (DeepSeek's, which OpenCode and most clients send), reasoning (OpenRouter's) or reasoning_details (OpenRouter's structured one). parseChat read only reasoning_content, so a request translated to a non-Chat upstream lost the thinking of every turn sent another way and the model went on without its own reasoning, which a tool-calling session shows from its second turn on. chattidy's passthrough has read all three since mistralThinking (yetone#494); the parse layer never got the same reader. The assistant branch now reads the thinking through reasoningText, messageReasoning's own reader, in the order the passthrough keeps it: reasoning_content, else reasoning, else reasoning_details' text. TestParseChatReadsEveryReasoningSpelling (a tool-calling turn per spelling) and TestParseChatTakesTheFirstReasoningSpellingSent fail without the change ("the assistant turn's parts: [{Kind:tool_call ...}]"). go vet -tags nogui ./internal/gateway/..., builds for windows, darwin and linux, and the package's chat/reasoning/thinking tests pass.
TryWorld2026
force-pushed
the
fix/chat-inbound-reasoning-spellings
branch
from
October 7, 2026 00:59
12530ea to
bb04efa
Compare
This branch has not been deployed
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.
gateway: a Chat turn's thinking is read in every spelling the client sends it back in
What is wrong
A client sends the previous assistant turn's thinking back in one of three
spellings:
reasoning_content(DeepSeek's, which OpenCode and most clientssend),
reasoning(OpenRouter's) orreasoning_details(OpenRouter'sstructured one).
parseChatread onlyreasoning_content, so a requesttranslated to a non-Chat upstream lost the thinking of every turn sent another
way, and the model went on without its own reasoning. A tool-calling session
shows it from its second turn on: the assistant has a thinking block in turn
one, none in turn three.
chattidy's passthrough has read all three since mistralThinking (#494); theparse layer never got the same reader.
What changed
The assistant branch now reads the thinking through
reasoningText,messageReasoning's own reader, in the order the passthrough keeps it:reasoning_content, elsereasoning, elsereasoning_details' text. Thethree fields are read as
json.RawMessageso one reader handles everyspelling, as the passthrough already does.
A turn sent in a spelling the reader does not know is still carried as before:
reasoningTextanswers empty and no thinking part is added.Semantic change (Gateway routing and fallback)
reasoningorreasoning_detailsproduced aMessagewith noPart{Kind: Thinking}.into whichever upstream the request is translated to.
docs/subsystems/gateway-routing.md;implementation
parseChatininternal/gateway/chat.go.Verification
TestParseChatReadsEveryReasoningSpellingfails without the change for thereasoningandreasoning_detailsspellings —the assistant turn's parts: [{Kind:tool_call ...}], the turn keeps its tool call and its thinking is gone— and passes with it. Its
reasoning_contentsubtest passes on the base aswell: upstream already reads that one, so it is a guard against dropping it
rather than a reproducer.
TestParseChatTakesTheFirstReasoningSpellingSentalso passes on the base and stays green.
go test -tags nogui ./internal/gateway/for the chat, reasoning andthinking tests;
go vet -tags nogui ./internal/gateway/...;GOOS=windows,GOOS=darwinandGOOS=linuxbuilds.internal/gatewaypackage leaves one failure on this Windows box,TestSweepBridgeProjectsTakesOnlyTheBridgesFolders, which needs a symlinkprivilege Windows does not grant here and fails the same way on the untouched
base. A second,
TestPluginStreamStalledClientKeepsOtherRequestsMoving, failedin one run of the package and passed in another, and passes under
-count=3.