mirror of
https://github.com/getcompanion-ai/co-mono.git
synced 2026-04-17 07:03:25 +00:00
fix(ai): avoid unsigned Gemini 3 tool calls (#741)
This commit is contained in:
parent
2c10cc6da9
commit
b18f401d9e
2 changed files with 90 additions and 10 deletions
|
|
@ -131,18 +131,29 @@ export function convertMessages<T extends GoogleApiType>(model: Model<T>, contex
|
|||
});
|
||||
}
|
||||
} else if (block.type === "toolCall") {
|
||||
const part: Part = {
|
||||
functionCall: {
|
||||
name: block.name,
|
||||
args: block.arguments,
|
||||
...(requiresToolCallId(model.id) ? { id: block.id } : {}),
|
||||
},
|
||||
};
|
||||
const thoughtSignature = resolveThoughtSignature(isSameProviderAndModel, block.thoughtSignature);
|
||||
if (thoughtSignature) {
|
||||
part.thoughtSignature = thoughtSignature;
|
||||
// Gemini 3 requires thoughtSignature on all function calls when thinking mode is enabled.
|
||||
// When replaying history from providers without thought signatures (e.g. Claude via Antigravity),
|
||||
// convert unsigned function calls to text to avoid API validation errors.
|
||||
const isGemini3 = model.id.toLowerCase().includes("gemini-3");
|
||||
if (isGemini3 && !thoughtSignature) {
|
||||
const argsStr = JSON.stringify(block.arguments, null, 2);
|
||||
parts.push({
|
||||
text: `[Tool Call: ${block.name}]\nArguments: ${argsStr}`,
|
||||
});
|
||||
} else {
|
||||
const part: Part = {
|
||||
functionCall: {
|
||||
name: block.name,
|
||||
args: block.arguments,
|
||||
...(requiresToolCallId(model.id) ? { id: block.id } : {}),
|
||||
},
|
||||
};
|
||||
if (thoughtSignature) {
|
||||
part.thoughtSignature = thoughtSignature;
|
||||
}
|
||||
parts.push(part);
|
||||
}
|
||||
parts.push(part);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue