diff --git a/src/uipath/platform/resume_triggers/_protocol.py b/src/uipath/platform/resume_triggers/_protocol.py index c8b85ffa4..530a7eb0e 100644 --- a/src/uipath/platform/resume_triggers/_protocol.py +++ b/src/uipath/platform/resume_triggers/_protocol.py @@ -1,7 +1,6 @@ """Implementation of UiPath resume trigger protocols.""" import json -import os import uuid from typing import Any @@ -301,7 +300,21 @@ async def read_trigger(self, trigger: UiPathResumeTrigger) -> Any | None: f"{e.message}", ) from e - return f"Batch transform completed. Modified file available at {os.path.abspath(destination_path)}" + # Upload result as job attachment (automatically links to job if available) + result_attachment_id = await uipath.jobs.create_attachment_async( + name=destination_path, + source_path=destination_path, + job_key=UiPathConfig.job_key, + ) + + mime_type = "text/csv" + + # Return attachment info + return { + "ID": str(result_attachment_id), + "FullName": destination_path, + "MimeType": mime_type, + } case UiPathResumeTriggerType.IXP_EXTRACTION: if trigger.item_key: diff --git a/tests/cli/test_hitl.py b/tests/cli/test_hitl.py index 6606fa722..aa144098a 100644 --- a/tests/cli/test_hitl.py +++ b/tests/cli/test_hitl.py @@ -520,15 +520,22 @@ async def test_read_batch_rag_trigger_successful( setup_test_env: None, ) -> None: """Test reading a successful batch rag trigger.""" - import os - task_id = "test-batch-rag-id" destination_path = "test/output.xlsx" - mock_download_async = AsyncMock(return_value=None) + attachment_id = "test-attachment-id" - with patch( - "uipath.platform.context_grounding._context_grounding_service.ContextGroundingService.download_batch_transform_result_async", - new=mock_download_async, + mock_download_async = AsyncMock(return_value=None) + mock_create_attachment_async = AsyncMock(return_value=attachment_id) + + with ( + patch( + "uipath.platform.context_grounding._context_grounding_service.ContextGroundingService.download_batch_transform_result_async", + new=mock_download_async, + ), + patch( + "uipath.platform.orchestrator._jobs_service.JobsService.create_attachment_async", + new=mock_create_attachment_async, + ), ): resume_trigger = UiPathResumeTrigger( trigger_type=UiPathResumeTriggerType.BATCH_RAG, @@ -542,16 +549,24 @@ async def test_read_batch_rag_trigger_successful( ) reader = UiPathResumeTriggerReader() result = await reader.read_trigger(resume_trigger) - assert ( - result - == f"Batch transform completed. Modified file available at {os.path.abspath(destination_path)}" - ) + + # Verify the result is a dictionary with attachment information + assert isinstance(result, dict) + assert result["ID"] == attachment_id + assert result["FullName"] == destination_path + assert result["MimeType"] == "text/csv" + mock_download_async.assert_called_once_with( task_id, destination_path, validate_status=True, index_name="test-index", ) + mock_create_attachment_async.assert_called_once_with( + name=destination_path, + source_path=destination_path, + job_key=None, + ) @pytest.mark.anyio async def test_read_batch_rag_trigger_pending(