fix(translator): only apply thoughtSignature to the first functionCall part in Gemini parallel tool calls

This commit is contained in:
diegosouzapw
2026-04-17 17:23:41 -03:00
parent 949a7a618f
commit 2fe67ada97
@@ -225,7 +225,7 @@ function openaiToGeminiBase(model, body, stream, toolNameOptions: GeminiToolName
.map((tc) => resolveGeminiThoughtSignature(tc.id, extractClientThoughtSignature(tc)))
.find((signature) => typeof signature === "string" && signature.length > 0);
const shouldUseEmbeddedSignature = !parts.some((p) => p.thoughtSignature);
let shouldUseEmbeddedSignature = !parts.some((p) => p.thoughtSignature);
for (const tc of msg.tool_calls) {
if (tc.type !== "function") continue;
@@ -239,6 +239,10 @@ function openaiToGeminiBase(model, body, stream, toolNameOptions: GeminiToolName
? firstPersistedSignature || signatureForToolCall || DEFAULT_THINKING_GEMINI_SIGNATURE
: undefined;
if (embeddedThoughtSignature) {
shouldUseEmbeddedSignature = false;
}
// Gemini expects the signature on the functionCall part itself.
parts.push({
...(embeddedThoughtSignature ? { thoughtSignature: embeddedThoughtSignature } : {}),