Automate browser based workflows with AI
Python aiapiautomationbrowserbrowser-automationcomputergptllmplaywrightpowerautomatepuppeteerpythonrpaseleniumvisionworkflow
fix(SKY-9745): surface cached-script block errors + add per-iteration logs (#5978)
pedrohsdb0db255f0269f
diff --git a/skyvern/forge/sdk/workflow/service.py b/skyvern/forge/sdk/workflow/service.pyindex 2c30fa806..064acf2fb 100644--- a/skyvern/forge/sdk/workflow/service.py+++ b/skyvern/forge/sdk/workflow/service.py@@ -2443,6 +2443,7 @@ class WorkflowService:fallback_episode_id: str | None = Noneform_fields_for_episode: list | None = None+ script_exception: Exception | None = Noneif valid_to_run_code:script_block = script_blocks_by_label[block.label]LOG.info(@@ -2579,6 +2580,7 @@ class WorkflowService:block_executed_with_code = Falseexcept Exception as e:block_exec_duration_ms = round((time.monotonic() - block_exec_start) * 1000, 1)+ script_exception = eLOG.warning("Failed to execute block with script code, falling back to AI",block_label=block.label,@@ -2856,8 +2858,13 @@ class WorkflowService:)if not workflow_run_block_result:+ if script_exception is not None:+ exc_message = str(script_exception) or "<no message>"+ no_block_result_reason = f"Script error ({type(script_exception).__name__}): {exc_message}"+ else:+ no_block_result_reason = "Block result is None"workflow_run = await self.mark_workflow_run_as_failed(- workflow_run_id=workflow_run_id, failure_reason="Block result is None"+ workflow_run_id=workflow_run_id, failure_reason=no_block_result_reason)return workflow_run, blocks_to_update, workflow_run_block_result, True, branch_metadatadiff --git a/skyvern/services/script_service.py b/skyvern/services/script_service.pyindex bf9420b49..e2dc98007 100644--- a/skyvern/services/script_service.py+++ b/skyvern/services/script_service.py@@ -3193,7 +3193,14 @@ async def loop(# step 5. start the looptry:# Iterates loop values; captures baseline files; yields items with metadata+ total_iterations = len(loop_values)for index, value in enumerate(loop_values):+ LOG.info(+ "skyvern.loop iteration",+ block_label=label,+ loop_index=index,+ total_iterations=total_iterations,+ )downloaded_file_signatures_before_iteration: list[tuple[str | None, str | None, str | None]] = []baseline_timed_out = Falsetry:@@ -3250,7 +3257,7 @@ async def loop(await _update_workflow_block(workflow_run_block_id,BlockStatus.failed,- failure_reason=str(e),+ failure_reason=str(e).strip() or type(e).__name__,output=block_validation_output.context.loop_output_values,label=label,)@@ -3383,6 +3390,11 @@ async def while_loop(# Invariant: loop_output_values was set to [] before the while True loop.assert block_validation_output.context.loop_output_values is not Noneblock_validation_output.context.loop_output_values.append([])+ LOG.info(+ "skyvern.while_loop iteration",+ block_label=label,+ loop_index=loop_idx,+ )yield SkyvernLoopItem(loop_idx, None)loop_idx += 1@@ -3398,7 +3410,7 @@ async def while_loop(await _update_workflow_block(workflow_run_block_id,BlockStatus.failed,- failure_reason=str(e),+ failure_reason=str(e).strip() or type(e).__name__,output=block_validation_output.context.loop_output_values,label=label,)