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

@@ -34,7 +34,14 @@ async def get_action_history(
{
"action": action.model_dump(
exclude_none=True,
include={"action_type", "element_id", "status", "reasoning", "option", "download"},
include={
"action_type",
"element_id",
"status",
"reasoning",
"option",
"download",
},
),
# use the last result of the action, because some actions(like chain_click)
# might have multiple results. Only the last one can represent the real result,

View File

@@ -60,9 +60,10 @@ from skyvern.schemas.scripts import (
ScriptFileCreate,
ScriptStatus,
)
from skyvern.schemas.steps import AgentStepOutput
from skyvern.schemas.workflows import BlockResult, BlockStatus, BlockType, FileStorageType, FileType
from skyvern.webeye.actions.action_types import ActionType
from skyvern.webeye.actions.actions import Action
from skyvern.webeye.actions.actions import Action, DecisiveAction
from skyvern.webeye.scraper.scraped_page import ElementTreeFormat
LOG = structlog.get_logger()
@@ -455,6 +456,8 @@ async def _create_workflow_block_run_and_task(
organization_id=organization_id,
workflow_run_id=workflow_run_id,
model=model,
# always use the action history for validation in caching/script run
include_action_history_in_verification=True,
)
task_id = task.task_id
@@ -593,12 +596,30 @@ async def _update_workflow_block(
final_output = output
if task_id:
if step_id:
# Build step output from script actions similar to agent flow
step_output = None
run_context = script_run_context_manager.get_run_context()
if run_context and run_context.actions_and_results:
# Extract errors from DecisiveActions (similar to agent flow)
errors: list[UserDefinedError] = []
for action, _ in run_context.actions_and_results:
if isinstance(action, DecisiveAction):
errors.extend(action.errors)
# Create AgentStepOutput similar to how agent does it
step_output = AgentStepOutput(
actions_and_results=run_context.actions_and_results,
action_results=[result for _, results in run_context.actions_and_results for result in results],
errors=errors,
)
await app.DATABASE.update_step(
step_id=step_id,
task_id=task_id,
organization_id=context.organization_id,
status=step_status,
is_last=is_last,
output=step_output,
)
updated_task = await app.DATABASE.update_task(
task_id=task_id,