Repository navigation
fix(backend): round-trip Vertex functionCall through the gateway - #13671
Merged
Git-on-my-level merged 1 commit intoSep 13, 2026
Merged
Git-on-my-level merged 1 commit into
Git-on-my-level merged 1 commit into
Conversation
Desktop Insight/Task only act on Gemini functionCall parts. The BasedHardware#12337 OpenAI-compatible Vertex adapter forwarded tools on the request and dropped them on the 200 response, which zeroed Advice Generated and Task Extracted. Failure-Class: new
There was a problem hiding this comment.
1 issue found across 3 files
Confidence score: 3/5
backend/llm_gateway/gateway/vertex_wire.pymarks split Vertex function-call SSE chunks as terminal and restarts indexes at 0 for each event, which can cause the desktop BFF to clear its pending call state; preserve chunk continuity across events and add coverage for split parallel and function-call responses.
Prompt for AI agents (unresolved issues)
Check if these issues are valid — if so, understand the root cause of each and fix them. If appropriate, use sub-agents to investigate and fix each issue separately.
<file name="backend/llm_gateway/gateway/vertex_wire.py">
<violation number="1" location="backend/llm_gateway/gateway/vertex_wire.py:473">
P2: When Vertex splits parallel function calls or a function-call response across SSE events, this chunk is marked terminal immediately and every event restarts indexes at 0. The desktop BFF therefore clears its pending calls after the first event and drops or overwrites subsequent calls. Preserve call indexes across the stream and emit `tool_calls` only on the actual terminal Vertex event, or buffer the function-call parts until termination.</violation>
</file>
Reply with feedback, questions, or to request a fix.
Re-trigger cubic
| finish_reason = ( | ||
| _vertex_finish_reason(raw_finish_reason, has_tool_calls=bool(tool_calls)) if raw_finish_reason else None | ||
| ) | ||
| if finish_reason is None and tool_calls: |
There was a problem hiding this comment.
P2: When Vertex splits parallel function calls or a function-call response across SSE events, this chunk is marked terminal immediately and every event restarts indexes at 0. The desktop BFF therefore clears its pending calls after the first event and drops or overwrites subsequent calls. Preserve call indexes across the stream and emit tool_calls only on the actual terminal Vertex event, or buffer the function-call parts until termination.
Prompt for AI agents
Check if this issue is valid — if so, understand the root cause and fix it. At backend/llm_gateway/gateway/vertex_wire.py, line 473:
<comment>When Vertex splits parallel function calls or a function-call response across SSE events, this chunk is marked terminal immediately and every event restarts indexes at 0. The desktop BFF therefore clears its pending calls after the first event and drops or overwrites subsequent calls. Preserve call indexes across the stream and emit `tool_calls` only on the actual terminal Vertex event, or buffer the function-call parts until termination.</comment>
<file context>
@@ -455,10 +465,23 @@ def _vertex_to_openai_stream_chunk(
+ finish_reason = (
+ _vertex_finish_reason(raw_finish_reason, has_tool_calls=bool(tool_calls)) if raw_finish_reason else None
+ )
+ if finish_reason is None and tool_calls:
+ finish_reason = 'tool_calls'
+ if not text and not tool_calls and finish_reason is None and usage is None:
</file context>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What changed and why
Gateway Vertex
generateContentalready forwarded OpenAItoolsto Gemini, but_vertex_to_openai_response/_vertex_to_openai_stream_chunkcopied text only. Company-paid desktop Insight/Task (sendImageToolLoop) only act onfunctionCall, so after #12337 hopped them through the gateway they got HTTP 200s with billed tokens and emitted zeroAdvice Generated/Task Extracted(#13666). JSON-schema Memory/Suggestion still worked because they parse text.This round-trips Vertex
functionCallparts to OpenAItool_calls(andfinish_reason: tool_calls), including functionCall-only candidates. Desktop BFF translation already maps that back to Gemini. No client change. Do not flipOMI_LLM_GATEWAY_FEATURE_MODE.Closes #13666
Product invariants affected
none
How it was verified
36 passed, including the new functionCall-only generateContent and SSE regressions.
Could not exercise live prod desktop Insight/Task in this PR; that path is the GKE LLM gateway. After merge, ship llm-gateway (not Cloud Run-only) so desktop-backend's existing hop sees the translator.
Tests
test_vertex_function_call_only_response_emits_openai_tool_callsandtest_vertex_function_call_sse_emits_openai_tool_call_deltainbackend/tests/unit/test_llm_gateway_vertex_provider.py. A Vertex candidate with onlyfunctionCall(no text) must emit OpenAItool_calls. That is the test that would have stayed red on #12337.Failure class (fixes)
Failure-Class: new
Failure-class transition narrative (only when needed)
Violated contract: an OpenAI-compatible Vertex adapter that advertises function tools must return those tool calls, not a 200 with empty/text-only content. Canonical guard: response + SSE normalizers emit
tool_callsfrom GeminifunctionCallparts; the two new hermetic tests are the prevention artifact. Registry file:.github/failure-classes/FC-gateway-vertex-drops-function-calls.json.