@@ -102,11 +102,18 @@ def __init__(self):
102102 self ._console = console_logger
103103 self ._rich_console = Console ()
104104 self ._project_id = os .getenv ("UIPATH_PROJECT_ID" , None )
105- if not self ._project_id :
105+ self ._agent_id = os .getenv ("UIPATH_AGENT_ID" ) or self ._project_id
106+ if not self ._agent_id :
106107 logger .warning (
107108 "Cannot report data to StudioWeb. Please set UIPATH_PROJECT_ID."
108109 )
109110
111+ # Map UIPATH_PROJECT_FILES_SOURCE (Local/Cloud) to the backend's
112+ # ProjectFilesSource enum integer. Without this every row the worker
113+ # creates lands as Cloud, and the UI's `?projectFilesSource=1` filter
114+ # never matches local-workspace runs.
115+ self ._project_files_source = self ._resolve_project_files_source ()
116+
110117 self .eval_set_ids : dict [str , str ] = {} # Track eval_set_id per execution
111118 self .eval_set_run_ids : dict [str , str ] = {}
112119 self .evaluators : dict [str , Any ] = {}
@@ -1089,6 +1096,29 @@ def _collect_coded_results(
10891096 evaluator_runs .append (evaluator_run )
10901097 return evaluator_runs , evaluator_scores_list
10911098
1099+ @staticmethod
1100+ def _resolve_project_files_source () -> int | None :
1101+ raw = os .getenv ("UIPATH_PROJECT_FILES_SOURCE" )
1102+ if not raw :
1103+ return None
1104+ normalized = raw .strip ().lower ()
1105+ if normalized == "local" :
1106+ return 1
1107+ if normalized == "cloud" :
1108+ return 0
1109+ try :
1110+ return int (normalized )
1111+ except ValueError :
1112+ logger .warning (
1113+ f"Unrecognized UIPATH_PROJECT_FILES_SOURCE value: { raw !r} ; ignoring."
1114+ )
1115+ return None
1116+
1117+ def _project_files_source_field (self ) -> dict [str , int ]:
1118+ if self ._project_files_source is None :
1119+ return {}
1120+ return {"projectFilesSource" : self ._project_files_source }
1121+
10921122 def _update_eval_run_spec (
10931123 self ,
10941124 assertion_runs : list [dict [str , Any ]],
@@ -1115,6 +1145,7 @@ def _update_eval_run_spec(
11151145 },
11161146 "completionMetrics" : {"duration" : int (execution_time * 1000 )},
11171147 "assertionRuns" : assertion_runs ,
1148+ ** self ._project_files_source_field (),
11181149 }
11191150
11201151 # Legacy backend expects payload wrapped in "request" field
@@ -1133,7 +1164,7 @@ def _update_eval_run_spec(
11331164 return RequestSpec (
11341165 method = "PUT" ,
11351166 endpoint = Endpoint (
1136- f"{ self ._get_endpoint_prefix ()} execution/agents/{ self ._project_id } /{ endpoint_suffix } evalRun"
1167+ f"{ self ._get_endpoint_prefix ()} execution/agents/{ self ._agent_id } /{ endpoint_suffix } evalRun"
11371168 ),
11381169 json = payload ,
11391170 headers = self ._tenant_header (),
@@ -1166,6 +1197,7 @@ def _update_coded_eval_run_spec(
11661197 },
11671198 "completionMetrics" : {"duration" : int (execution_time * 1000 )},
11681199 "evaluatorRuns" : evaluator_runs ,
1200+ ** self ._project_files_source_field (),
11691201 }
11701202
11711203 # Log the payload for debugging coded eval run updates
@@ -1181,7 +1213,7 @@ def _update_coded_eval_run_spec(
11811213 return RequestSpec (
11821214 method = "PUT" ,
11831215 endpoint = Endpoint (
1184- f"{ self ._get_endpoint_prefix ()} execution/agents/{ self ._project_id } /{ endpoint_suffix } evalRun"
1216+ f"{ self ._get_endpoint_prefix ()} execution/agents/{ self ._agent_id } /{ endpoint_suffix } evalRun"
11851217 ),
11861218 json = payload ,
11871219 headers = self ._tenant_header (),
@@ -1235,6 +1267,7 @@ def _create_eval_run_spec(
12351267 "evalSnapshot" : eval_snapshot ,
12361268 # Backend expects integer status
12371269 "status" : EvaluationStatus .IN_PROGRESS .value ,
1270+ ** self ._project_files_source_field (),
12381271 }
12391272
12401273 # Legacy backend expects payload wrapped in "request" field
@@ -1253,7 +1286,7 @@ def _create_eval_run_spec(
12531286 return RequestSpec (
12541287 method = "POST" ,
12551288 endpoint = Endpoint (
1256- f"{ self ._get_endpoint_prefix ()} execution/agents/{ self ._project_id } /{ endpoint_suffix } evalRun"
1289+ f"{ self ._get_endpoint_prefix ()} execution/agents/{ self ._agent_id } /{ endpoint_suffix } evalRun"
12571290 ),
12581291 json = payload ,
12591292 headers = self ._tenant_header (),
@@ -1283,14 +1316,15 @@ def _create_eval_set_run_spec(
12831316 eval_set_id_value = str (uuid .uuid5 (uuid .NAMESPACE_DNS , eval_set_id ))
12841317
12851318 inner_payload : dict [str , Any ] = {
1286- "agentId" : self ._project_id ,
1319+ "agentId" : self ._agent_id ,
12871320 "evalSetId" : eval_set_id_value ,
12881321 "agentSnapshot" : agent_snapshot .model_dump (by_alias = True ),
12891322 # Backend expects integer status
12901323 "status" : EvaluationStatus .IN_PROGRESS .value ,
12911324 "numberOfEvalsExecuted" : no_of_evals ,
12921325 # Source is required by the backend (0 = coded SDK)
12931326 "source" : 0 ,
1327+ ** self ._project_files_source_field (),
12941328 }
12951329
12961330 # Both coded and legacy send payload directly at root level
@@ -1309,7 +1343,7 @@ def _create_eval_set_run_spec(
13091343 return RequestSpec (
13101344 method = "POST" ,
13111345 endpoint = Endpoint (
1312- f"{ self ._get_endpoint_prefix ()} execution/agents/{ self ._project_id } /{ endpoint_suffix } evalSetRun"
1346+ f"{ self ._get_endpoint_prefix ()} execution/agents/{ self ._agent_id } /{ endpoint_suffix } evalSetRun"
13131347 ),
13141348 json = payload ,
13151349 headers = self ._tenant_header (),
@@ -1353,6 +1387,7 @@ def _update_eval_set_run_spec(
13531387 # Backend expects integer status
13541388 "status" : status .value ,
13551389 "evaluatorScores" : evaluator_scores_list ,
1390+ ** self ._project_files_source_field (),
13561391 }
13571392
13581393 # Legacy backend expects payload wrapped in "request" field
@@ -1374,7 +1409,7 @@ def _update_eval_set_run_spec(
13741409 return RequestSpec (
13751410 method = "PUT" ,
13761411 endpoint = Endpoint (
1377- f"{ self ._get_endpoint_prefix ()} execution/agents/{ self ._project_id } /{ endpoint_suffix } evalSetRun"
1412+ f"{ self ._get_endpoint_prefix ()} execution/agents/{ self ._agent_id } /{ endpoint_suffix } evalSetRun"
13781413 ),
13791414 json = payload ,
13801415 headers = self ._tenant_header (),
@@ -1406,12 +1441,12 @@ def _get_eval_runs_spec(
14061441
14071442 if is_coded :
14081443 endpoint_path = (
1409- f"{ prefix } execution/agents/{ self ._project_id } /coded/"
1444+ f"{ prefix } execution/agents/{ self ._agent_id } /coded/"
14101445 f"evalSets/{ eval_set_id } /evalSetRuns/{ eval_set_run_id } /evalRuns"
14111446 )
14121447 else :
14131448 endpoint_path = (
1414- f"{ prefix } execution/agents/{ self ._project_id } /"
1449+ f"{ prefix } execution/agents/{ self ._agent_id } /"
14151450 f"evalSets/{ eval_set_id } /evalSetRuns/{ eval_set_run_id } /evalRuns"
14161451 )
14171452
@@ -1420,10 +1455,14 @@ def _get_eval_runs_spec(
14201455 f"eval_set_run_id={ eval_set_run_id } , evaluation_id={ evaluation_id } , coded={ is_coded } "
14211456 )
14221457
1458+ # The backend's listing endpoint filters by projectFilesSource +
1459+ # cloudUserId so the UI only shows the caller's local rows. Mirror
1460+ # that here so resume lookups match the row written by the same
1461+ # worker session.
14231462 return RequestSpec (
14241463 method = "GET" ,
14251464 endpoint = Endpoint (endpoint_path ),
1426- params = {}, # No query params needed - evalSetRunId is in the path
1465+ params = self . _project_files_source_field (),
14271466 headers = self ._tenant_header (),
14281467 )
14291468
0 commit comments