@@ -845,6 +845,48 @@ async def test_handle_a2a_response_with_task_submitted_and_no_update(self):
845845 assert A2A_METADATA_PREFIX + "task_id" in result .custom_metadata
846846 assert A2A_METADATA_PREFIX + "context_id" in result .custom_metadata
847847
848+ @pytest .mark .asyncio
849+ async def test_handle_a2a_response_with_task_working_and_no_update (self ):
850+ """Test successful A2A response handling with streaming task and no update."""
851+ mock_a2a_task = Mock (spec = A2ATask )
852+ mock_a2a_task .id = "task-123"
853+ mock_a2a_task .context_id = "context-123"
854+ mock_a2a_task .status = Mock (spec = A2ATaskStatus )
855+ mock_a2a_task .status .state = TaskState .working
856+
857+ # Create a proper Event mock that can handle custom_metadata
858+ mock_a2a_part = Mock (spec = TextPart )
859+ mock_event = Event (
860+ author = self .agent .name ,
861+ invocation_id = self .mock_context .invocation_id ,
862+ branch = self .mock_context .branch ,
863+ content = genai_types .Content (role = "model" , parts = [mock_a2a_part ]),
864+ )
865+
866+ with patch (
867+ "google.adk.agents.remote_a2a_agent.convert_a2a_task_to_event"
868+ ) as mock_convert :
869+ mock_convert .return_value = mock_event
870+
871+ result = await self .agent ._handle_a2a_response (
872+ (mock_a2a_task , None ), self .mock_context
873+ )
874+
875+ assert result == mock_event
876+ mock_convert .assert_called_once_with (
877+ mock_a2a_task ,
878+ self .agent .name ,
879+ self .mock_context ,
880+ self .mock_a2a_part_converter ,
881+ )
882+ # Check the parts are updated as Thought
883+ assert result .content .parts [0 ].thought is True
884+ assert result .content .parts [0 ].thought_signature is None
885+ # Check that metadata was added
886+ assert result .custom_metadata is not None
887+ assert A2A_METADATA_PREFIX + "task_id" in result .custom_metadata
888+ assert A2A_METADATA_PREFIX + "context_id" in result .custom_metadata
889+
848890 @pytest .mark .asyncio
849891 async def test_handle_a2a_response_with_task_status_update_with_message (self ):
850892 """Test handling of a task status update with a message."""
0 commit comments