Skip to content

feat(live): filter internal _adk_live artifact parts from live session history - #7346

Open
copybara-service[bot] wants to merge 1 commit into
mainfrom
copybara/990462563
Open

copybara-service[bot] wants to merge 1 commit into
mainfrom
copybara/990462563

Conversation

@copybara-service

Copy link
Copy Markdown

feat(live): filter internal _adk_live artifact parts from live session 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.

…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
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant