feat(live): filter internal _adk_live artifact parts from live session history - #7346
Open
copybara-service[bot] wants to merge 1 commit into
Open
copybara-service[bot] wants to merge 1 commit into
copybara-service[bot] wants to merge 1 commit into
Conversation
…n history When `RunConfig.save_live_blob=True` is enabled, live sessions persist realtime audio, image, and video blobs to `BaseArtifactService` and record internal `artifact://.../_adk_live/...` `FileData` references (including single-frame media files and multi-frame `application/zip` archives) on session events. Those internal `artifact://` URIs cannot be resolved by the Gemini Live API's `send_client_content` endpoint when session history is replayed on reconnect or agent transfer. This change adds `is_adk_live_artifact_part()` in `utils/content_utils.py` and updates `filter_audio_parts()` (used by `GeminiLlmConnection.send_history()`) to strip internal `_adk_live` artifact `FileData` parts while preserving text, inline media blobs, and external `gs://` / `https://` `FileData` parts. Testing Plan: - Added unit tests in `tests/unittests/utils/test_content_utils.py` covering `is_adk_live_artifact_part()` (multi-frame `.zip`, single-frame `.jpeg`, parameterized/uppercase MIME strings, `None` fields, external `gs://` URIs, and inline blobs) and `filter_audio_parts()`. - Added `test_send_history_filters_out_adk_live_artifact_parts` in `tests/unittests/models/test_gemini_llm_connection.py`. PiperOrigin-RevId: 990462563
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.
feat(live): filter internal _adk_live artifact parts from live session history
When
RunConfig.save_live_blob=Trueis enabled, live sessions persist realtimeaudio, image, and video blobs to
BaseArtifactServiceand record internalartifact://.../_adk_live/...FileDatareferences (including single-framemedia files and multi-frame
application/ziparchives) on session events.Those internal
artifact://URIs cannot be resolved by the Gemini Live API'ssend_client_contentendpoint when session history is replayed on reconnect oragent transfer.
This change adds
is_adk_live_artifact_part()inutils/content_utils.pyandupdates
filter_audio_parts()(used byGeminiLlmConnection.send_history())to strip internal
_adk_liveartifactFileDataparts while preserving text,inline media blobs, and external
gs:///https://FileDataparts.Testing Plan:
tests/unittests/utils/test_content_utils.pycoveringis_adk_live_artifact_part()(multi-frame.zip, single-frame.jpeg,parameterized/uppercase MIME strings,
Nonefields, externalgs://URIs,and inline blobs) and
filter_audio_parts().test_send_history_filters_out_adk_live_artifact_partsintests/unittests/models/test_gemini_llm_connection.py.