@@ -21,7 +21,6 @@ import {
2121 convertOpenAIContentToParts ,
2222 extractTextContent ,
2323 tryParseJSON ,
24- generateRequestId ,
2524 generateSessionId ,
2625 cleanJSONSchemaForAntigravity ,
2726} from "../helpers/geminiHelper.ts" ;
@@ -97,6 +96,7 @@ type CloudCodeEnvelope = {
9796
9897type GeminiToolNameOptions = {
9998 stripNamespace ?: boolean ;
99+ functionResponseShape ?: "result" | "output" ;
100100} ;
101101
102102function buildChangedToolNameMap ( toolNameMap : Map < string , string > ) : Map < string , string > | null {
@@ -296,7 +296,10 @@ function openaiToGeminiBase(model, body, stream, toolNameOptions: GeminiToolName
296296 functionResponse : {
297297 id : fid ,
298298 name : name ,
299- response : { result : parsedResp } ,
299+ response :
300+ toolNameOptions . functionResponseShape === "output"
301+ ? { output : typeof resp === "string" ? resp : JSON . stringify ( resp ) }
302+ : { result : parsedResp } ,
300303 } ,
301304 } ) ;
302305 }
@@ -350,8 +353,16 @@ export function openaiToGeminiRequest(model, body, stream) {
350353}
351354
352355// OpenAI -> Gemini CLI (Cloud Code Assist)
353- export function openaiToGeminiCLIRequest ( model , body , stream ) {
354- const gemini = openaiToGeminiBase ( model , body , stream , { stripNamespace : true } ) ;
356+ export function openaiToGeminiCLIRequest (
357+ model ,
358+ body ,
359+ stream ,
360+ options : { functionResponseShape ?: "result" | "output" } = { }
361+ ) {
362+ const gemini = openaiToGeminiBase ( model , body , stream , {
363+ stripNamespace : true ,
364+ functionResponseShape : options . functionResponseShape ,
365+ } ) ;
355366
356367 // Add thinking config for CLI
357368 if ( body . reasoning_effort ) {
@@ -413,7 +424,7 @@ function wrapInCloudCodeEnvelope(model, geminiCLI, credentials = null, isAntigra
413424 : {
414425 model : cleanModel ,
415426 project : projectId ,
416- user_prompt_id : generateRequestId ( ) ,
427+ user_prompt_id : generateUUID ( ) ,
417428 request : {
418429 contents : geminiCLI . contents ,
419430 systemInstruction : geminiCLI . systemInstruction ,
@@ -443,7 +454,7 @@ function wrapInCloudCodeEnvelope(model, geminiCLI, credentials = null, isAntigra
443454 }
444455 } else {
445456 // Gemini CLI's native Cloud Code envelope uses snake_case identifiers.
446- envelope . request . session_id = generateSessionId ( ) ;
457+ envelope . request . session_id = envelope . user_prompt_id ;
447458 envelope . request . safetySettings = geminiCLI . safetySettings ;
448459 }
449460
@@ -619,7 +630,11 @@ register(
619630 FORMATS . OPENAI ,
620631 FORMATS . GEMINI_CLI ,
621632 ( model , body , stream , credentials ) =>
622- wrapInCloudCodeEnvelope ( model , openaiToGeminiCLIRequest ( model , body , stream ) , credentials ) ,
633+ wrapInCloudCodeEnvelope (
634+ model ,
635+ openaiToGeminiCLIRequest ( model , body , stream , { functionResponseShape : "output" } ) ,
636+ credentials
637+ ) ,
623638 null
624639) ;
625640register ( FORMATS . OPENAI , FORMATS . ANTIGRAVITY , openaiToAntigravityRequest , null ) ;
0 commit comments