Skip to content

Commit 98b97b6

Browse files
committed
fix: use Struct format for Gemini functionResponse to ensure API compatibility
The Gemini API expects functionResponse.response to be a Struct (object), not a plain string. This change wraps the pruned content message in an object with 'name' and 'content' fields to match the expected format.
1 parent edc6932 commit 98b97b6

File tree

1 file changed

+5
-2
lines changed

1 file changed

+5
-2
lines changed

lib/fetch-wrapper/gemini.ts

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -78,12 +78,15 @@ export async function handleGemini(
7878
contentModified = true
7979
replacedCount++
8080
// Preserve thoughtSignature if present (required for Gemini 3 Pro)
81-
// Only replace the response content, not the structure
81+
// response must be a Struct (object), not a plain string
8282
return {
8383
...part,
8484
functionResponse: {
8585
...part.functionResponse,
86-
response: PRUNED_CONTENT_MESSAGE
86+
response: {
87+
name: part.functionResponse.name,
88+
content: PRUNED_CONTENT_MESSAGE
89+
}
8790
}
8891
}
8992
}

0 commit comments

Comments
 (0)