From 28829952890c39dbdb4463b2b67ff241d0e9ef6d Mon Sep 17 00:00:00 2001 From: Sanjay Siddharth MJ <64358580+SanjaySiddharth@users.noreply.github.com> Date: Sun, 9 Nov 2025 16:00:09 -0800 Subject: [PATCH] fix: Fixes DeprecationWarning when using send method Merge https://github.com/google/adk-python/pull/3352 Replace send() method with send_realtime_input() to fix DeprecationWarning ### Link to Issue or Description of Change **1. Link to an existing issue (if applicable):** - Closes: #2393 ### Testing Plan Have run unit test for test_live_request_queue.py **Unit Tests:** - [ ] I have added or updated unit tests for my change. - [x] All unit tests pass locally. Summary : tests/unittests/agents/test_live_request_queue.py::test_send_realtime PASSED [100%] **Manual End-to-End (E2E) Tests:** ### Checklist - [x] I have read the [CONTRIBUTING.md](https://github.com/google/adk-python/blob/main/CONTRIBUTING.md) document. - [x] I have performed a self-review of my own code. - [x] 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. - [x] New and existing unit tests pass locally with my changes. - [x] I have manually tested my changes end-to-end. - [ ] Any dependent changes have been merged and published in downstream modules. Tested both API variants. Co-authored-by: Hangfei Lin COPYBARA_INTEGRATE_REVIEW=https://github.com/google/adk-python/pull/3352 from SanjaySiddharth:fix-dep-session.send b23b641a63ff20d1f2dbd9abd519f8facf0aab77 PiperOrigin-RevId: 830182844 --- src/google/adk/models/gemini_llm_connection.py | 4 ++-- tests/unittests/models/test_gemini_llm_connection.py | 6 +++++- 2 files changed, 7 insertions(+), 3 deletions(-) diff --git a/src/google/adk/models/gemini_llm_connection.py b/src/google/adk/models/gemini_llm_connection.py index 3ffdc102..0f1c9670 100644 --- a/src/google/adk/models/gemini_llm_connection.py +++ b/src/google/adk/models/gemini_llm_connection.py @@ -106,10 +106,10 @@ class GeminiLlmConnection(BaseLlmConnection): input: The input to send to the model. """ if isinstance(input, types.Blob): - input_blob = input.model_dump() # The blob is binary and is very large. So let's not log it. logger.debug('Sending LLM Blob.') - await self._gemini_session.send(input=input_blob) + await self._gemini_session.send_realtime_input(media=input) + elif isinstance(input, types.ActivityStart): logger.debug('Sending LLM activity start signal.') await self._gemini_session.send_realtime_input(activity_start=input) diff --git a/tests/unittests/models/test_gemini_llm_connection.py b/tests/unittests/models/test_gemini_llm_connection.py index e706a972..6d3e6857 100644 --- a/tests/unittests/models/test_gemini_llm_connection.py +++ b/tests/unittests/models/test_gemini_llm_connection.py @@ -45,7 +45,11 @@ async def test_send_realtime_default_behavior( await gemini_connection.send_realtime(test_blob) # Should call send once - mock_gemini_session.send.assert_called_once_with(input=test_blob.model_dump()) + mock_gemini_session.send_realtime_input.assert_called_once_with( + media=test_blob + ) + # Should not call .send function + mock_gemini_session.send.assert_not_called() @pytest.mark.asyncio