add action result, including downloaded files to step.output for both agent and caching runs (#4477)

This commit is contained in:
Shuchang Zheng
2026-01-18 11:17:02 -08:00
committed by GitHub
parent 6a32d8b696
commit bd041ed52f
8 changed files with 245 additions and 16 deletions

View File

@@ -125,6 +125,8 @@ class Action(BaseModel):
file_name: str | None = None
file_url: str | None = None
download: bool | None = None
download_triggered: bool | None = None # Whether a download was triggered by this action
downloaded_files: list[str] | None = None # List of file names downloaded by this action
is_upload_file_tag: bool | None = None
text: str | None = None
input_or_select_context: InputOrSelectContext | None = None

View File

@@ -481,8 +481,22 @@ class ActionHandler:
if not download_triggered:
results[-1].download_triggered = False
action.download_triggered = False
return results
results[-1].download_triggered = True
action.download_triggered = True
# Calculate newly downloaded file names
new_file_paths = set(list_files_after) - set(list_files_before)
downloaded_file_names = [os.path.basename(fp) for fp in new_file_paths]
if downloaded_file_names:
results[-1].downloaded_files = downloaded_file_names
action.downloaded_files = downloaded_file_names
LOG.info(
"Downloaded files captured",
downloaded_files=downloaded_file_names,
workflow_run_id=task.workflow_run_id,
)
await check_downloading_files_and_wait_for_download_to_complete(
download_dir=download_dir,

View File

@@ -14,6 +14,7 @@ class ActionResult(BaseModel):
step_retry_number: int | None = None
step_order: int | None = None
download_triggered: bool | None = None
downloaded_files: list[str] | None = None # Actual file names that were downloaded
# None is used for old data so that we can differentiate between old and new data which only has boolean
interacted_with_sibling: bool | None = None
interacted_with_parent: bool | None = None
@@ -33,6 +34,8 @@ class ActionResult(BaseModel):
results.append(f"step_retry_number={self.step_retry_number}")
if self.download_triggered is not None:
results.append(f"download_triggered={self.download_triggered}")
if self.downloaded_files is not None:
results.append(f"downloaded_files={self.downloaded_files}")
if self.interacted_with_sibling is not None:
results.append(f"interacted_with_sibling={self.interacted_with_sibling}")
if self.interacted_with_parent is not None:
@@ -51,6 +54,7 @@ class ActionSuccess(ActionResult):
self,
data: dict[str, Any] | list | str | None = None,
download_triggered: bool | None = None,
downloaded_files: list[str] | None = None,
interacted_with_sibling: bool = False,
interacted_with_parent: bool = False,
):
@@ -58,6 +62,7 @@ class ActionSuccess(ActionResult):
success=True,
data=data,
download_triggered=download_triggered,
downloaded_files=downloaded_files,
interacted_with_sibling=interacted_with_sibling,
interacted_with_parent=interacted_with_parent,
)