Skip to content

refactor(live): generalize AudioCacheManager into CacheManager and wire live flow - #7348

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

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

Conversation

@copybara-service

Copy link
Copy Markdown

refactor(live): generalize AudioCacheManager into CacheManager and wire live flow

  • Introduce CacheManager, CacheConfig, and RealtimeCacheEntry in google.adk.live._cache_manager with cache_blob() MIME routing, shared _save_artifact_and_build_event(), and concurrent fault-isolated cache flushing (asyncio.gather(..., return_exceptions=True)).
  • Keep google.adk.live._audio_cache_manager and google.adk.flows.llm_flows.audio_cache_manager as backward-compatible re-export shims (AudioCacheManager = CacheManager, AudioCacheConfig = CacheConfig).
  • Add input_media_realtime_cache and output_media_realtime_cache fields to InvocationContext.
  • Add self.cache_manager = CacheManager() to BaseLlmFlow with deprecated __getattribute__/__setattr__ forwarding for self.audio_cache_manager.
  • Update _live_llm_flow.py and _flow_utils.py to use flow.cache_manager and cache_manager.cache_blob().

Testing Plan:

  • Added unit tests in tests/unittests/live/test_cache_manager.py covering CacheManager, CacheConfig, cache_blob() routing, MIME parameter normalization, and concurrent fault-isolated flushing.
  • Updated tests/unittests/live/test_audio_cache_manager.py, tests/unittests/live/test_flow_utils.py, tests/unittests/live/test_live_llm_flow.py, and tests/unittests/flows/llm_flows/test_audio_cache_manager.py.

…re live flow

- Introduce `CacheManager`, `CacheConfig`, and `RealtimeCacheEntry` in `google.adk.live._cache_manager` with `cache_blob()` MIME routing, shared `_save_artifact_and_build_event()`, and concurrent fault-isolated cache flushing (`asyncio.gather(..., return_exceptions=True)`).
- Keep `google.adk.live._audio_cache_manager` and `google.adk.flows.llm_flows.audio_cache_manager` as backward-compatible re-export shims (`AudioCacheManager = CacheManager`, `AudioCacheConfig = CacheConfig`).
- Add `input_media_realtime_cache` and `output_media_realtime_cache` fields to `InvocationContext`.
- Add `self.cache_manager = CacheManager()` to `BaseLlmFlow` with deprecated `__getattribute__`/`__setattr__` forwarding for `self.audio_cache_manager`.
- Update `_live_llm_flow.py` and `_flow_utils.py` to use `flow.cache_manager` and `cache_manager.cache_blob()`.

Testing Plan:
- Added unit tests in `tests/unittests/live/test_cache_manager.py` covering `CacheManager`, `CacheConfig`, `cache_blob()` routing, MIME parameter normalization, and concurrent fault-isolated flushing.
- Updated `tests/unittests/live/test_audio_cache_manager.py`, `tests/unittests/live/test_flow_utils.py`, `tests/unittests/live/test_live_llm_flow.py`, and `tests/unittests/flows/llm_flows/test_audio_cache_manager.py`.

PiperOrigin-RevId: 990565785
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