fix(google): deliver tool calls before combined turn completion - #7164
Open
noooooooookro wants to merge 1 commit into
Open
fix(google): deliver tool calls before combined turn completion#7164noooooooookro wants to merge 1 commit into
noooooooookro wants to merge 1 commit into
Conversation
|
|
longcw
reviewed
Sep 9, 2026
| self._handle_server_content(response.server_content) | ||
| self._handle_server_content( | ||
| response.server_content, | ||
| defer_completion=response.tool_call is not None, |
Contributor
There was a problem hiding this comment.
The behaviour is right. Maybe a cleaner shape: finalize here instead of in the two handlers. Both _handle_server_content and _handle_tool_calls are only called from this loop, so the loop can own the decision and the defer_completion flag goes away.
if response.server_content:
self._handle_server_content(response.server_content)
if response.tool_call:
self._handle_tool_calls(response.tool_call)
if ((sc := response.server_content) and sc.turn_complete) or response.tool_call:
self._mark_current_generation_done()Then drop the turn_complete finalize at the end of _handle_server_content and the one at the end of _handle_tool_calls. Same order as now: content, then the calls, then close, in one iteration.
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.
Fixes #7151
What changed
Google Realtime can send a single response containing both terminal server content and a tool call. The receive loop now defers generation finalization for that server content, keeping the function channel open until the tool call is delivered. Existing responses without a tool call retain their current completion behavior.
Validation
python -m pytest tests/test_plugin_google_realtime.py -q(19 passed)ruff check livekit-plugins/livekit-plugins-google/livekit/plugins/google/realtime/realtime_api.py tests/test_plugin_google_realtime.pyruff format --check livekit-plugins/livekit-plugins-google/livekit/plugins/google/realtime/realtime_api.py tests/test_plugin_google_realtime.py