fix(translator): only apply thoughtSignature to the first functionCall part in Gemini parallel tool calls
This commit is contained in:
@@ -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 } : {}),
|
||||
|
||||
Reference in New Issue
Block a user