Repository navigation
fix(google): deliver tool calls before combined turn completion - #7164
noooooooookro wants to merge 1 commit into
Conversation
|
|
| self._handle_server_content(response.server_content) | ||
| self._handle_server_content( | ||
| response.server_content, | ||
| defer_completion=response.tool_call is not None, |
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.
|
@noooooooookro, I opened #8376 for the same crash. It implements @longcw's review suggestion on this PR: the receive loop finalizes the generation once, after both handlers, so the |
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