@@ -642,3 +642,90 @@ def test_streaming_with_context_window_compression_config():
642642 llm_request_sent_to_mock .live_connect_config .context_window_compression .sliding_window .target_tokens
643643 == 500
644644 )
645+
646+
647+ def test_streaming_with_avatar_config ():
648+ """Test avatar_config propagation and video content through run_live.
649+
650+ Verifies:
651+ 1. avatar_config from RunConfig is propagated to live_connect_config.
652+ 2. Video inline_data from the model flows through events correctly.
653+ """
654+ # Mock model returns video content followed by turn_complete.
655+ video_response = LlmResponse (
656+ content = types .Content (
657+ role = 'model' ,
658+ parts = [
659+ types .Part (
660+ inline_data = types .Blob (
661+ data = b'video_data' , mime_type = 'video/mp4'
662+ )
663+ )
664+ ],
665+ ),
666+ )
667+ turn_complete_response = LlmResponse (
668+ turn_complete = True ,
669+ )
670+
671+ mock_model = testing_utils .MockModel .create (
672+ [video_response , turn_complete_response ]
673+ )
674+
675+ root_agent = Agent (
676+ name = 'root_agent' ,
677+ model = mock_model ,
678+ tools = [],
679+ )
680+
681+ runner = testing_utils .InMemoryRunner (
682+ root_agent = root_agent , response_modalities = ['VIDEO' ]
683+ )
684+
685+ run_config = RunConfig (
686+ response_modalities = ['VIDEO' ],
687+ avatar_config = types .AvatarConfig (avatar_name = 'Kai' ),
688+ )
689+
690+ live_request_queue = LiveRequestQueue ()
691+ live_request_queue .send_realtime (
692+ blob = types .Blob (data = b'\x00 \xFF ' , mime_type = 'audio/pcm' )
693+ )
694+ res_events = runner .run_live (live_request_queue , run_config )
695+
696+ assert res_events is not None , 'Expected a list of events, got None.'
697+ assert (
698+ len (res_events ) > 0
699+ ), 'Expected at least one response, but got an empty list.'
700+ assert len (mock_model .requests ) == 1
701+
702+ # 1. Verify avatar_config was propagated to the live_connect_config.
703+ llm_request_sent_to_mock = mock_model .requests [0 ]
704+ assert llm_request_sent_to_mock .live_connect_config is not None
705+ assert llm_request_sent_to_mock .live_connect_config .avatar_config is not None
706+ assert (
707+ llm_request_sent_to_mock .live_connect_config .avatar_config .avatar_name
708+ == 'Kai'
709+ )
710+
711+ # 2. Verify video content flows through events.
712+ video_events = [
713+ e
714+ for e in res_events
715+ if e .content
716+ and e .content .parts
717+ and any (
718+ p .inline_data
719+ and p .inline_data .mime_type
720+ and p .inline_data .mime_type .startswith ('video/' )
721+ for p in e .content .parts
722+ )
723+ ]
724+ assert video_events , 'Expected at least one event with video inline_data.'
725+
726+ video_event = video_events [0 ]
727+ assert video_event .content .role == 'model'
728+ video_part = video_event .content .parts [0 ]
729+ assert video_part .inline_data is not None
730+ assert video_part .inline_data .data == b'video_data'
731+ assert video_part .inline_data .mime_type == 'video/mp4'
0 commit comments