fix(core): preserve reasoning across model switches (#45401)

This commit is contained in:
Aiden Cline
2026-08-26 17:52:41 -05:00
committed by GitHub
Unverified
parent 954cdc7bc8
commit 5ac4156eb2
2 changed files with 3 additions and 2 deletions
@@ -157,6 +157,7 @@ const assistant = (message: SessionMessage.Assistant, model: Model.Ref, provider
providerMetadata: reuseProviderMetadata ? providerMetadata(providerMetadataKey, item.state) : undefined,
},
]
// Let the destination adapter handle readable reasoning after a model/provider switch.
if (item.type === "reasoning")
return reuseProviderMetadata
? [
@@ -167,7 +168,7 @@ const assistant = (message: SessionMessage.Assistant, model: Model.Ref, provider
},
]
: item.text.length > 0
? [{ type: "text", text: item.text }]
? [{ type: message.error === undefined ? "reasoning" : "text", text: item.text }]
: []
// Call-side metadata is model-scoped proof of generation (Gemini thought
// signatures, OpenAI encrypted reasoning): only the producing model may
@@ -984,7 +984,7 @@ Recent work
)
expect(messages[0]?.content).toEqual([
{ type: "text", text: "Visible thought" },
{ type: "reasoning", text: "Visible thought" },
{
type: "tool-call",
id: "hosted-old-model",