-
Notifications
You must be signed in to change notification settings - Fork 3.7k
fix(google): don't start a generation from audio trailing a tool call #7196
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
Darshak03
wants to merge
4
commits into
livekit:main
Choose a base branch
from
Darshak03:fix/gemini-realtime-trailing-model-turn
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
+82
−1
Open
Changes from all commits
Commits
Show all changes
4 commits
Select commit
Hold shift + click to select a range
5b948b0
fix(google): don't start a generation from audio trailing a tool call
Darshak03 aaa9ba6
fix(google): clear the tool-call suppression when the call is answered
Darshak03 1411e25
fix(google): only clear the suppression for the turn the response ans…
Darshak03 987aaf8
fix(google): clear the tool-call suppression from server events only
Darshak03 File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
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
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
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.
Uh oh!
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
🟡 Requested replies remain suppressed
When
generate_replyfollows an unanswered tool call, its request reaches Gemini while_turn_ended_by_tool_callremains set. The model response cannot open a generation, so the returned future times out.Was this helpful? React with 👍 or 👎 to provide feedback.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I do not think this one should be changed, because the fix for it reopens the finding that was just resolved above.
The two are in direct tension. The earlier comment was that clearing before the request reaches Gemini lets trailing audio resolve the pending reply with stale content. Clearing when the request does reach the socket narrows that window but does not close it — audio from the finished turn can still arrive after our send. So adding a wrapper to clear on send trades a user-visible wrong reply for a timeout in a case that is already blocked for another reason.
On that case: an unanswered tool call blocks the model by design. From #6785, which fixed exactly this: "A realtime model holds each call it emitted open until it is answered, so Gemini Live stopped responding and later
generate_reply()calls produced no generation (#6569)." So with a call outstanding,generate_replyyields no generation at the protocol level, whatever this flag does. The timeout is #6569's, not this flag's.It also needs
turn_completeto be missing. In the call this PR is based on, the tool call andturn_completeland within the same millisecond, andturn_completeclears the flag — so the window where the flag is still set and a reply is requested is about that wide, and any tool doing real work is far outside it.Between the two, suppression that lasts slightly too long in a case the protocol already blocks seems better than suppression that ends slightly too early in a case that silently attaches the wrong audio to the caller's reply. The model that ends such a turn without a
turn_completeis covered by the tool-response clear, so it cannot be suppressed indefinitely either.