fix(ai): preserve unsigned tool call context for Gemini 3 with anti-mimicry note

Instead of skipping unsigned tool calls entirely (which lobotomizes context),
convert them to text with an explicit note telling the model this is historical
context from a different model and not a format to mimic.

This preserves tool call/result context when switching from providers without
thought signatures (e.g. Claude via Antigravity) to Gemini 3.
This commit is contained in:
Mario Zechner 2026-01-16 23:42:39 +01:00
parent 1405e30492
commit 5d3e7d5aaa
2 changed files with 6 additions and 2 deletions

View file

@ -135,11 +135,12 @@ export function convertMessages<T extends GoogleApiType>(model: Model<T>, contex
// 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.
// We include a note telling the model this is historical context to prevent mimicry.
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}`,
text: `[Historical context: a different model called tool "${block.name}" with arguments: ${argsStr}. Do not mimic this format - use proper function calling.]`,
});
} else {
const part: Part = {