From f87016a5fee795c5ea97436e3a707d3ad42b592b Mon Sep 17 00:00:00 2001 From: Peter Steinberger Date: Wed, 14 Jan 2026 23:27:47 +0000 Subject: [PATCH] fix: handle unsigned tool calls for gemini 3 --- patches/@mariozechner__pi-ai@0.45.7.patch | 52 +++++++++++++++++++++++ pnpm-lock.yaml | 10 ++--- 2 files changed, 57 insertions(+), 5 deletions(-) diff --git a/patches/@mariozechner__pi-ai@0.45.7.patch b/patches/@mariozechner__pi-ai@0.45.7.patch index 82f4d5819..e21f645a8 100644 --- a/patches/@mariozechner__pi-ai@0.45.7.patch +++ b/patches/@mariozechner__pi-ai@0.45.7.patch @@ -79,3 +79,55 @@ index 5f9a17e..48631a7 100644 -//# sourceMappingURL=openai-responses.js.map \ No newline at end of file +//# sourceMappingURL=openai-responses.js.map +diff --git a/dist/providers/google-shared.js b/dist/providers/google-shared.js +index 47dc045..706157a 100644 +--- a/dist/providers/google-shared.js ++++ b/dist/providers/google-shared.js +@@ -130,18 +130,30 @@ + } + } + else if (block.type === "toolCall") { +- const 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 switching from a provider that doesn't support 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 = { ++ functionCall: { ++ name: block.name, ++ args: block.arguments, ++ ...(requiresToolCallId(model.id) ? { id: block.id } : {}), ++ }, ++ }; ++ if (thoughtSignature) { ++ part.thoughtSignature = thoughtSignature; ++ } ++ parts.push(part); + } +- parts.push(part); + } + } + if (parts.length === 0) +@@ -280,4 +292,4 @@ + return "error"; + } + } +-//# sourceMappingURL=google-shared.js.map +\ No newline at end of file ++//# sourceMappingURL=google-shared.js.map diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml index 7266472d5..edd6fa07b 100644 --- a/pnpm-lock.yaml +++ b/pnpm-lock.yaml @@ -9,7 +9,7 @@ overrides: patchedDependencies: '@mariozechner/pi-ai@0.45.7': - hash: 899187c39b551e0b611a32006f5f06bc329d3478fe4bac9bac044b2df079e2cd + hash: e8b10ed06e0bcda571016bc4979ef2c5bf8a99ccade0201a3f74bc1914754fe9 path: patches/@mariozechner__pi-ai@0.45.7.patch importers: @@ -36,7 +36,7 @@ importers: version: 0.45.3(ws@8.19.0)(zod@4.3.5) '@mariozechner/pi-ai': specifier: 0.45.7 - version: 0.45.7(patch_hash=899187c39b551e0b611a32006f5f06bc329d3478fe4bac9bac044b2df079e2cd)(ws@8.19.0)(zod@4.3.5) + version: 0.45.7(patch_hash=e8b10ed06e0bcda571016bc4979ef2c5bf8a99ccade0201a3f74bc1914754fe9)(ws@8.19.0)(zod@4.3.5) '@mariozechner/pi-coding-agent': specifier: ^0.45.3 version: 0.45.3(ws@8.19.0)(zod@4.3.5) @@ -5067,7 +5067,7 @@ snapshots: '@mariozechner/pi-agent-core@0.45.3(ws@8.19.0)(zod@4.3.5)': dependencies: - '@mariozechner/pi-ai': 0.45.7(patch_hash=899187c39b551e0b611a32006f5f06bc329d3478fe4bac9bac044b2df079e2cd)(ws@8.19.0)(zod@4.3.5) + '@mariozechner/pi-ai': 0.45.7(patch_hash=e8b10ed06e0bcda571016bc4979ef2c5bf8a99ccade0201a3f74bc1914754fe9)(ws@8.19.0)(zod@4.3.5) '@mariozechner/pi-tui': 0.45.3 transitivePeerDependencies: - '@modelcontextprotocol/sdk' @@ -5078,7 +5078,7 @@ snapshots: - ws - zod - '@mariozechner/pi-ai@0.45.7(patch_hash=899187c39b551e0b611a32006f5f06bc329d3478fe4bac9bac044b2df079e2cd)(ws@8.19.0)(zod@4.3.5)': + '@mariozechner/pi-ai@0.45.7(patch_hash=e8b10ed06e0bcda571016bc4979ef2c5bf8a99ccade0201a3f74bc1914754fe9)(ws@8.19.0)(zod@4.3.5)': dependencies: '@anthropic-ai/sdk': 0.71.2(zod@4.3.5) '@aws-sdk/client-bedrock-runtime': 3.967.0 @@ -5105,7 +5105,7 @@ snapshots: '@mariozechner/clipboard': 0.3.0 '@mariozechner/jiti': 2.6.2 '@mariozechner/pi-agent-core': 0.45.3(ws@8.19.0)(zod@4.3.5) - '@mariozechner/pi-ai': 0.45.7(patch_hash=899187c39b551e0b611a32006f5f06bc329d3478fe4bac9bac044b2df079e2cd)(ws@8.19.0)(zod@4.3.5) + '@mariozechner/pi-ai': 0.45.7(patch_hash=e8b10ed06e0bcda571016bc4979ef2c5bf8a99ccade0201a3f74bc1914754fe9)(ws@8.19.0)(zod@4.3.5) '@mariozechner/pi-tui': 0.45.3 chalk: 5.6.2 cli-highlight: 2.1.11