This commit is contained in:
Junghwan 2026-04-24 09:40:32 -06:00 committed by GitHub
commit bf26759ab0
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
2 changed files with 27 additions and 8 deletions

View file

@ -280,6 +280,28 @@ describe("convertToResponsesApiInput", () => {
}),
)
})
it("should not replay Anthropic thinking blocks as assistant-visible text", () => {
const messages: Anthropic.Messages.MessageParam[] = [
{
role: "assistant",
content: [
{ type: "thinking", thinking: "SECRET_CHAIN_OF_THOUGHT", signature: "sig-1" } as any,
{ type: "text", text: "visible answer" },
],
},
]
const result = convertToResponsesApiInput(messages)
expect(result).toEqual([
{
type: "message",
role: "assistant",
content: [{ type: "output_text", text: "visible answer" }],
},
])
})
})
describe("multi-turn conversations", () => {

View file

@ -53,14 +53,11 @@ export function convertToResponsesApiInput(messages: Anthropic.Messages.MessageP
})
break
case "thinking":
// Include reasoning if it has content
if ((part as any).thinking && (part as any).thinking.trim().length > 0) {
input.push({
type: "message",
role: "assistant",
content: [{ type: "output_text", text: `[Thinking] ${(part as any).thinking}` }],
})
}
// Anthropic thinking blocks represent hidden reasoning. The
// Responses API input format does not have a compatible hidden
// reasoning representation for these persisted blocks, so replaying
// them as normal assistant-visible text changes conversation
// semantics. Skip them instead of flattening them into output_text.
break
}
}