fix(core): preserve compatible reasoning replay

This commit is contained in:
Jack 2026-07-16 07:42:32 +00:00
commit b6208a8c50
16 changed files with 169 additions and 22 deletions

View file

@ -74,17 +74,13 @@ const assistant = (message: SessionMessage.Assistant, model: Model) => {
const content = message.content.flatMap((item): ContentPart[] => {
if (item.type === "text") return [{ type: "text", text: item.text }]
if (item.type === "reasoning")
return sameModel
? [
{
type: "reasoning",
text: item.text,
providerMetadata: reuseProviderMetadata ? item.providerMetadata : undefined,
},
]
: item.text.length > 0
? [{ type: "text", text: item.text }]
: []
return [
{
type: "reasoning",
text: item.text,
providerMetadata: reuseProviderMetadata ? item.providerMetadata : undefined,
},
]
const call = toolCall(item, reuseProviderMetadata ? item.provider?.metadata : undefined)
if (item.provider?.executed !== true) return [call]
const result = toolResult(

View file

@ -457,7 +457,7 @@ Recent work
)
expect(messages[0]?.content).toEqual([
{ type: "text", text: "Visible thought" },
{ type: "reasoning", text: "Visible thought", providerMetadata: undefined },
{
type: "tool-call",
id: "hosted-old-model",