Skip to content

fix(llminternal): skip live responses that carry nothing - #2301

Merged
jjsasha63 merged 3 commits into
google:mainfrom
jjsasha63:fix/live-empty-responses
Nov 13, 2026
Merged

jjsasha63 merged 3 commits into
google:mainfrom
jjsasha63:fix/live-empty-responses

Conversation

@jjsasha63

Copy link
Copy Markdown
Contributor

Please ensure you have read the contribution guide before creating a pull request.

Linked issue

None.

2. Describe the change:

Problem:

RunLive turns every response from the Live API connection into an event. That includes the empty response built from the server's setupComplete message, along with any other mesage that converts to an empty model.LLMResponse (an empty serverContent, 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 RunLive now skips a response that carries nothing. Such a response has no Content, ErrorCode, GroundingMetadata, UsageMetadata, input or output transcription, or SessionResumptionHandle, and is neither Interrupted nor TurnComplete. This matches the check in adk-python's postprocess_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:

  • All unit tests pass locally.

New tests in internal/llminternal/base_flow_live_test.go:

  • TestRunLiveSkipsEmptyResponses: a fake Live server sends setupComplete, one message, then a model turn. The test chekcs which events arrive before the model turn. An empty serverContent yields none. turnComplete, interrupted, input transcription, output transcription, usage metadata and a session resumption update each yield exactly one event, with the expected LLMResponse. setupComplete never 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_cleanly and TestRunLiveCloseStopsIdleSession used 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.

TestRunLiveCeilingIgnoresConsumerLatency in internal/llminternal/live_reconnect_test.go relied 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-less turnComplete frame per connection. Reading the clock in the consumer loop (time.Since(connectedAt) instead of ce.at.Sub(connectedAt) in base_flow.go) fails it again, as it does on main. A comment in TestRunLiveReconnectSurvivesATransientDrop no longer cites the setup-complete event.

With your source change reverted and your tests kept, which test fails?

All seven subtests of TestRunLiveSkipsEmptyResponses fail, because each sees an extra empty event before the expected one. I also removed each condition of isEmptyLiveResponse in turn. Every removal failed at least one test: the matching TestRunLiveSkipsEmptyResponses subtest for the wire-visible fields, and TestIsEmptyLiveResponse/content, /error_code or /grounding_metadata for 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 and go mod tidy -diff prints nothing.

Parity (adk-python v2.12.0; line numbers refer to that tag)

  • I read src/google/adk/live/_live_llm_flow.py (postprocess_live_flow, lines 405 to 420). The skip conditions match it field for field.
  • adk-python also checks voice_activity, and model.LLMResponse has 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.
  • adk-python's other live post-processing (request processors, the separate event per transcription or resumption update) is not part of this change.

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_response
  • tests/unittests/live/test_live_llm_flow.py::test_postprocess_live_flow_yields_input_and_output_transcriptions
  • tests/unittests/live/test_live_llm_flow.py::test_postprocess_live_flow_yields_session_resumption_update
  • tests/unittests/flows/llm_flows/test_live_tool_callbacks.py::test_live_sync_before_tool_callback
  • tests/unittests/flows/llm_flows/test_plugin_tool_callbacks.py::test_live_before_tool_callback
  • tests/unittests/flows/llm_flows/test_plugin_tool_callbacks.py::test_live_plugin_before_tool_callback_takes_priority

The tool callback scenarios count the events of a live run. before this change adk-go yielded one extra empty event at the start.

Checklist

  • I have read the CONTRIBUTING.md document.
  • I have performed a self-review of my own code.
  • I have commented my code, particularly in hard-to-understand areas.
  • I have added tests that prove my fix is effective or that my feature works.
  • New and existing unit tests pass locally with my changes.
  • I have manually tested my changes end-to-end.
  • Any dependent changes have been merged and published in downstream modules.

Additional context

None.

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.
@jjsasha63 jjsasha63 self-assigned this Nov 13, 2026
@jjsasha63
jjsasha63 requested a review from wojtas000 November 13, 2026 07:49

@wojtas000 wojtas000 left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

@jjsasha63
jjsasha63 merged commit 8cddb9d into google:main Nov 13, 2026
15 checks passed
@jjsasha63
jjsasha63 deleted the fix/live-empty-responses branch November 13, 2026 09:37
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)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants