In index.js the streamGenerateContent handler (reachable via POST /v1beta/models/:model:streamGenerateContent) calls executePromptStreaming and emits incremental text deltas correctly for plain-text turns. However, when callerTools is non-empty and runAgentTurn resolves with toolCalls.length > 0, the streaming response emits only a final candidates chunk with functionCall parts — it never emits the intermediate response.function_call_arguments.delta-equivalent Gemini streaming events that clients like Vertex AI SDK or LangChain's Gemini integration expect (candidates[].content.parts[].functionCall arriving before the terminal chunk). This is visible by comparing the OpenAI streaming path in createProxyFetchHandler (which emits a dedicated tool_calls delta chunk before the finish chunk) against the Gemini streaming path, which has no equivalent. Gemini streaming clients that buffer until they see a function-call part mid-stream will hang or mis-parse the response. The fix mirrors the OpenAI streaming approach: emit a pre-finish chunk containing the functionCall parts when toolCalls.length > 0.
In
index.jsthestreamGenerateContenthandler (reachable viaPOST /v1beta/models/:model:streamGenerateContent) callsexecutePromptStreamingand emits incrementaltextdeltas correctly for plain-text turns. However, whencallerToolsis non-empty andrunAgentTurnresolves withtoolCalls.length > 0, the streaming response emits only a finalcandidateschunk withfunctionCallparts — it never emits the intermediateresponse.function_call_arguments.delta-equivalent Gemini streaming events that clients like Vertex AI SDK or LangChain's Gemini integration expect (candidates[].content.parts[].functionCallarriving before the terminal chunk). This is visible by comparing the OpenAI streaming path increateProxyFetchHandler(which emits a dedicatedtool_callsdelta chunk before the finish chunk) against the Gemini streaming path, which has no equivalent. Gemini streaming clients that buffer until they see a function-call part mid-stream will hang or mis-parse the response. The fix mirrors the OpenAI streaming approach: emit a pre-finish chunk containing thefunctionCallparts whentoolCalls.length > 0.