fix: send anthropic thinking blocks also when thinking text is empty (#6457)
fixes: #6376
This commit is contained in:
@@ -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");
|
||||
|
||||
Reference in New Issue
Block a user