Repository navigation
fix(llminternal): skip live responses that carry nothing - #2301
Merged
Merged
Conversation
The live read loop in RunLive turned every response from the Live API into an event. That included the empty response built from setupComplete. As a result, every live run started with an event that had no content, and the session kept it. adk-python's live flow yields no event for a response that has no content, no error code and no grounding metadata. The response must also not be interrupted or turn complete, and must carry no transcription, no usage metadata and no session resumption update. This logic is postprocess_live_flow in live/_live_llm_flow.py. RunLive now skips the same responses before they become evnets. The session resumption handle is still recorded before the check.
wojtas000
approved these changes
Nov 13, 2026
wojtas000
left a comment
Contributor
There was a problem hiding this comment.
With the continue removed, all seven TestRunLiveSkipsEmptyResponses cases fail, and every response LiveConnection.Recv builds that carries data (content, tool calls, turn signals, transcriptions, usage metadata, a new resumption handle) still reaches the caller. The resumption handle and audio caching run before the check, and the reconnect budget never counted content-less events, so the retry delay and the reconnect limit behave as they do on main.
7 of 8 tasks
wolo-lab
added a commit
that referenced
this pull request
Nov 16, 2026
…2071, #1249, #2070, #2190, #2301, #2310, #2308) (#2350) * fix(llminternal): keep a streamed text chunk's thought signature on the merged part (#2071) (cherry picked from commit 28201d6) * test(llminternal): pin keep-last semantics for streaming usage metadata (#1249) (cherry picked from commit afe6c86) * fix(llminternal): keep ModelVersion on the aggregated streaming response (#2070) (cherry picked from commit 8be9129) * fix(llminternal): drop nil parts in the streaming aggregator (#2190) (cherry picked from commit 46ff99b) * fix(llminternal): skip live responses that carry nothing (#2301) (cherry picked from commit 8cddb9d) * fix(llminternal): keep responses that carry only grounding metadata (#2310) (cherry picked from commit fc6de07) * fix(llminternal): keep streamed function-call and event ids stable (#2308) (cherry picked from commit 3188db9)
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.
Please ensure you have read the contribution guide before creating a pull request.
Linked issue
None.
2. Describe the change:
Problem:
RunLiveturns every response from the Live API connection into an event. That includes the empty response built from the server'ssetupCompletemessage, along with any other mesage that converts to an emptymodel.LLMResponse(an emptyserverContent, for example). So every live run starts with an event that has no content, and the session stores it. adk-python yields no event for these responses.Solution:
The read loop in
RunLivenow skips a response that carries nothing. Such a response has noContent,ErrorCode,GroundingMetadata,UsageMetadata, input or output transcription, orSessionResumptionHandle, and is neitherInterruptednorTurnComplete. This matches the check in adk-python'spostprocess_live_flow. The resumption handle is still recorded before the check, and audio caching only runs for responses with content, so neither is affected.Behavior change
A live run no longer yields the content-less event that used to arrive first, after
setupComplete. Other responses that carry nothing are dropped too. Callers that waited for that first event as a "connection is up" signal will not get it. Nothing changes for responses with content, control signals, transcriptions, usage metadata or a new resumption handle.Testing Plan
Unit Tests:
New tests in
internal/llminternal/base_flow_live_test.go:TestRunLiveSkipsEmptyResponses: a fake Live server sendssetupComplete, one message, then a model turn. The test chekcs which events arrive before the model turn. An emptyserverContentyields none.turnComplete,interrupted, input transcription, output transcription, usage metadata and a session resumption update each yield exactly one event, with the expectedLLMResponse.setupCompletenever yields an event in any case.TestIsEmptyLiveResponse: covers the fields the wire conversion does not set today (ErrorCode,GroundingMetadata), plus content, a zero response and a partial-only response.I updated two tests.
TestRunLiveNoGoroutineLeak/parent_ctx_cancel_exits_cleanlyandTestRunLiveCloseStopsIdleSessionused the setup-complete event to know the connection was up. The fake server now sends one model turn after setup, and the tests synchronize on that turn. Each test still checks the same teardown path.TestRunLiveCeilingIgnoresConsumerLatencyininternal/llminternal/live_reconnect_test.gorelied on the setup-complete event as the one event each connection produces. Without that event it passed even with the connections life measured in the wrong place. Its fake server now sends one content-lessturnCompleteframe per connection. Reading the clock in the consumer loop (time.Since(connectedAt)instead ofce.at.Sub(connectedAt)inbase_flow.go) fails it again, as it does on main. A comment inTestRunLiveReconnectSurvivesATransientDropno longer cites the setup-complete event.With your source change reverted and your tests kept, which test fails?
All seven subtests of
TestRunLiveSkipsEmptyResponsesfail, because each sees an extra empty event before the expected one. I also removed each condition ofisEmptyLiveResponsein turn. Every removal failed at least one test: the matchingTestRunLiveSkipsEmptyResponsessubtest for the wire-visible fields, andTestIsEmptyLiveResponse/content,/error_codeor/grounding_metadatafor the rest.go test -race -count=1 ./internal/llminternal/...passes.go test -count=1 ./...passes in all 119 packages that have tests.golangci-lint run --new-from-rev=origin/main ./...reports 0 issues andgo mod tidy -diffprints nothing.Parity (adk-python v2.12.0; line numbers refer to that tag)
src/google/adk/live/_live_llm_flow.py(postprocess_live_flow, lines 405 to 420). The skip conditions match it field for field.voice_activity, andmodel.LLMResponsehas no such field yet. A session resumption update with no new handle is skipped here, because Go carries only the handle, while adk-python yields it.Manual End-to-End (E2E) Tests:
I did not run this against a live model. These adk-python tests check the same skip:
tests/unittests/live/test_live_llm_flow.py::test_postprocess_live_flow_skips_empty_responsetests/unittests/live/test_live_llm_flow.py::test_postprocess_live_flow_yields_input_and_output_transcriptionstests/unittests/live/test_live_llm_flow.py::test_postprocess_live_flow_yields_session_resumption_updatetests/unittests/flows/llm_flows/test_live_tool_callbacks.py::test_live_sync_before_tool_callbacktests/unittests/flows/llm_flows/test_plugin_tool_callbacks.py::test_live_before_tool_callbacktests/unittests/flows/llm_flows/test_plugin_tool_callbacks.py::test_live_plugin_before_tool_callback_takes_priorityThe tool callback scenarios count the events of a live run. before this change adk-go yielded one extra empty event at the start.
Checklist
Additional context
None.