@@ -773,6 +773,87 @@ async def test_async_stream_query_with_content(
773773 events .append (event )
774774 assert len (events ) == 1
775775
776+ @pytest .mark .asyncio
777+ @pytest .mark .usefixtures (
778+ "default_instrumentor_builder_mock" , "get_project_id_mock"
779+ )
780+ async def test_async_stream_query_with_multimodal_content (self ):
781+ """Tests async_stream_query with a multimodal Content dictionary."""
782+ # pylint: disable=protected-access
783+ app = agent_engines .AdkApp (agent = _TEST_AGENT )
784+ assert app ._tmpl_attrs .get ("runner" ) is None
785+ app .set_up ()
786+ runner_kwargs = {}
787+
788+ async def run_async (** kwargs ):
789+ runner_kwargs .update (kwargs )
790+ async for event in _MockRunner ().run_async ():
791+ yield event
792+
793+ app ._tmpl_attrs ["runner" ] = mock .Mock (run_async = run_async )
794+ video_message = {
795+ "role" : "user" ,
796+ "parts" : [
797+ {
798+ "file_data" : {
799+ "file_uri" : (
800+ "gs://cloud-samples-data/generative-ai/video/pixel8.mp4"
801+ ),
802+ "mime_type" : "video/mp4" ,
803+ },
804+ },
805+ {
806+ "text" : "Describe the attached media in 5 words!" ,
807+ },
808+ ],
809+ }
810+ events = []
811+ async for event in app .async_stream_query (
812+ user_id = _TEST_USER_ID ,
813+ message = video_message ,
814+ ):
815+ events .append (event )
816+ assert len (events ) == 1
817+ expected_content = types .Content (
818+ role = "user" ,
819+ parts = [
820+ types .Part (
821+ file_data = types .FileData (
822+ file_uri = (
823+ "gs://cloud-samples-data/generative-ai/video/pixel8.mp4"
824+ ),
825+ mime_type = "video/mp4" ,
826+ ),
827+ ),
828+ types .Part (
829+ text = "Describe the attached media in 5 words!" ,
830+ ),
831+ ],
832+ )
833+ assert runner_kwargs ["new_message" ] == expected_content
834+
835+ # Also verify the REST / requests JSON payload round-trips through
836+ # StreamQueryReasoningEngineRequest into async_stream_query.
837+ rest_request = aip_types .StreamQueryReasoningEngineRequest .from_json (
838+ json .dumps ({
839+ "class_method" : "async_stream_query" ,
840+ "input" : {
841+ "user_id" : _TEST_USER_ID ,
842+ "message" : video_message ,
843+ },
844+ })
845+ )
846+ assert rest_request .class_method == "async_stream_query"
847+ runner_kwargs .clear ()
848+ rest_events = [
849+ event
850+ async for event in getattr (app , rest_request .class_method )(
851+ ** _utils .to_dict (rest_request )["input" ]
852+ )
853+ ]
854+ assert len (rest_events ) == 1
855+ assert runner_kwargs ["new_message" ] == expected_content
856+
776857 @pytest .mark .asyncio
777858 async def test_streaming_agent_run_with_events (
778859 self ,
0 commit comments