Record output of cached task run when there's extracted information (#4140)
This commit is contained in:
@@ -1194,7 +1194,7 @@ async def run_task(
|
||||
cache_key: str | None = None,
|
||||
engine: RunEngine = RunEngine.skyvern_v1,
|
||||
model: dict[str, Any] | None = None,
|
||||
) -> None:
|
||||
) -> dict[str, Any] | list | str | None:
|
||||
cache_key = cache_key or label
|
||||
cached_fn = script_run_context_manager.get_cached_fn(cache_key)
|
||||
|
||||
@@ -1213,7 +1213,7 @@ async def run_task(
|
||||
context = skyvern_context.ensure_context()
|
||||
context.prompt = prompt
|
||||
try:
|
||||
await _run_cached_function(cached_fn)
|
||||
output = await _run_cached_function(cached_fn)
|
||||
|
||||
# Update block status to completed if workflow block was created
|
||||
if workflow_run_block_id:
|
||||
@@ -1221,9 +1221,11 @@ async def run_task(
|
||||
workflow_run_block_id,
|
||||
BlockStatus.completed,
|
||||
task_id=task_id,
|
||||
output=output,
|
||||
step_id=step_id,
|
||||
label=cache_key,
|
||||
)
|
||||
return output
|
||||
|
||||
except Exception as e:
|
||||
LOG.exception("Failed to run task block. Falling back to AI run.")
|
||||
@@ -1238,6 +1240,7 @@ async def run_task(
|
||||
error=e,
|
||||
workflow_run_block_id=workflow_run_block_id,
|
||||
)
|
||||
return None
|
||||
finally:
|
||||
# clear the prompt in the RunContext
|
||||
context.prompt = None
|
||||
@@ -1255,12 +1258,13 @@ async def run_task(
|
||||
engine=RunEngine.skyvern_v1,
|
||||
model=model,
|
||||
)
|
||||
await task_block.execute_safe(
|
||||
block_output = await task_block.execute_safe(
|
||||
workflow_run_id=block_validation_output.workflow_run_id,
|
||||
parent_workflow_run_block_id=block_validation_output.context.parent_workflow_run_block_id,
|
||||
organization_id=block_validation_output.organization_id,
|
||||
browser_session_id=block_validation_output.browser_session_id,
|
||||
)
|
||||
return block_output.output_parameter_value
|
||||
|
||||
|
||||
async def download(
|
||||
|
||||
Reference in New Issue
Block a user