mirror of
https://github.com/RooVetGit/Roo-Code.git
synced 2026-09-10 22:41:14 +00:00
Merge dc07aaa1f5 into 7adbfec2a4
This commit is contained in:
commit
db01f776d9
2 changed files with 40 additions and 5 deletions
|
|
@ -107,7 +107,7 @@ describe("convertAnthropicMessageToGemini", () => {
|
|||
expect(() => convertAnthropicMessageToGemini(anthropicMessage)).toThrow("Unsupported image source type")
|
||||
})
|
||||
|
||||
it("should convert a message with tool use", () => {
|
||||
it("should convert a message with tool use (no thought signature in history)", () => {
|
||||
const anthropicMessage: Anthropic.Messages.MessageParam = {
|
||||
role: "assistant",
|
||||
content: [
|
||||
|
|
@ -133,7 +133,40 @@ describe("convertAnthropicMessageToGemini", () => {
|
|||
name: "calculator",
|
||||
args: { operation: "add", numbers: [2, 3] },
|
||||
},
|
||||
thoughtSignature: "skip_thought_signature_validator",
|
||||
},
|
||||
],
|
||||
},
|
||||
])
|
||||
})
|
||||
|
||||
it("should attach thoughtSignature to functionCall when a real signature exists", () => {
|
||||
const anthropicMessage: Anthropic.Messages.MessageParam = {
|
||||
role: "assistant",
|
||||
content: [
|
||||
{ type: "thoughtSignature", thoughtSignature: "real-sig-abc" } as any,
|
||||
{ type: "text", text: "Let me calculate that for you." },
|
||||
{
|
||||
type: "tool_use",
|
||||
id: "calc-123",
|
||||
name: "calculator",
|
||||
input: { operation: "add", numbers: [2, 3] },
|
||||
},
|
||||
],
|
||||
}
|
||||
|
||||
const result = convertAnthropicMessageToGemini(anthropicMessage)
|
||||
|
||||
expect(result).toEqual([
|
||||
{
|
||||
role: "model",
|
||||
parts: [
|
||||
{ text: "Let me calculate that for you." },
|
||||
{
|
||||
functionCall: {
|
||||
name: "calculator",
|
||||
args: { operation: "add", numbers: [2, 3] },
|
||||
},
|
||||
thoughtSignature: "real-sig-abc",
|
||||
},
|
||||
],
|
||||
},
|
||||
|
|
|
|||
|
|
@ -41,11 +41,13 @@ export function convertAnthropicContentToGemini(
|
|||
|
||||
// Determine the signature to attach to function calls.
|
||||
// If we're in a mode that expects signatures (includeThoughtSignatures is true):
|
||||
// 1. Use the actual signature if we found one in the history/content.
|
||||
// 2. Fallback to "skip_thought_signature_validator" if missing (e.g. cross-model history).
|
||||
// - Use the actual signature if we found one in the history/content.
|
||||
// - If no real signature exists, omit it (undefined) so the API accepts the request.
|
||||
// Gemini 3.1+ models reject the synthetic "skip_thought_signature_validator" bypass
|
||||
// that worked with earlier Gemini 3 models.
|
||||
let functionCallSignature: string | undefined
|
||||
if (includeThoughtSignatures) {
|
||||
functionCallSignature = activeThoughtSignature || "skip_thought_signature_validator"
|
||||
functionCallSignature = activeThoughtSignature
|
||||
}
|
||||
|
||||
if (typeof content === "string") {
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue