fix: send anthropic thinking blocks also when thinking text is empty (#6457)

fixes: #6376
This commit is contained in:
David Brailovsky
2026-07-09 23:25:22 +02:00
committed by GitHub
parent 1a2542b11b
commit 6731a0ba9e
2 changed files with 13 additions and 5 deletions
@@ -32,10 +32,10 @@ function makeModel(allowEmptySignature?: boolean): Model<"anthropic-messages"> {
};
}
function makeContext(thinkingSignature: string): Context {
function makeContext(thinkingSignature: string, thinking = "internal reasoning"): Context {
const assistant: AssistantMessage = {
role: "assistant",
content: [{ type: "thinking", thinking: "internal reasoning", thinkingSignature }],
content: [{ type: "thinking", thinking, thinkingSignature }],
provider: "xiaomi-token-plan-ams",
api: "anthropic-messages",
model: "mimo-v2.5-pro",
@@ -80,6 +80,12 @@ describe("Anthropic empty thinking signature compat", () => {
expect(assistant?.content).toEqual([{ type: "text", text: "internal reasoning" }]);
});
it("preserves empty thinking text when the signature is present", async () => {
const payload = await capturePayload(makeModel(), makeContext("signed-thinking", ""));
const assistant = payload.messages?.find((message) => message.role === "assistant");
expect(assistant?.content).toEqual([{ type: "thinking", thinking: "", signature: "signed-thinking" }]);
});
it("preserves empty-signature thinking when allowEmptySignature is enabled", async () => {
const payload = await capturePayload(makeModel(true), makeContext(" "));
const assistant = payload.messages?.find((message) => message.role === "assistant");