Automate browser based workflows with AI
Python aiapiautomationbrowserbrowser-automationcomputergptllmplaywrightpowerautomatepuppeteerpythonrpaseleniumvisionworkflow
Log failed script actions with reconstructed call for debugging (#5276)
pedrohsdb087904aece89
diff --git a/skyvern/core/script_generations/script_skyvern_page.py b/skyvern/core/script_generations/script_skyvern_page.pyindex a3b8fb7a4..e314697f0 100644--- a/skyvern/core/script_generations/script_skyvern_page.py+++ b/skyvern/core/script_generations/script_skyvern_page.py@@ -261,13 +261,28 @@ class ScriptSkyvernPage(SkyvernPage):except Exception as e:call.error = eaction_status = ActionStatus.failed- # Note: Action status would be updated to failed here if update method existed- # Print failure in script mode- if context and context.script_mode:- print(f" ✗ Failed: {str(e)}")+ # Build a readable representation of the failed call+ call_parts = [f"page.{fn.__name__}("]+ if args:+ call_parts.append(repr(args[0]) if len(args) == 1 else repr(args))+ key_kwargs = {k: v for k, v in kwargs.items() if k in ("selector", "prompt", "mode") and v is not None}+ if key_kwargs:+ if args:+ call_parts.append(", ")+ call_parts.append(", ".join(f"{k}={repr(v)}" for k, v in key_kwargs.items()))+ call_parts.append(")")+ call_repr = "".join(call_parts)++ LOG.warning(+ "Script action failed",+ action_type=action.value if hasattr(action, "value") else str(action),+ call=call_repr,+ error=str(e),+ script_id=context.script_id if context else None,+ workflow_run_id=context.workflow_run_id if context else None,+ )- # LLM fallback hook could go here ...raisefinally:# Add a small buffer between cached actions to give slow pages time to settlediff --git a/skyvern/services/script_service.py b/skyvern/services/script_service.pyindex d88d7b94c..5ef77b8b3 100644--- a/skyvern/services/script_service.py+++ b/skyvern/services/script_service.py@@ -1089,13 +1089,12 @@ async def _fallback_to_ai_run(script_step_id = context.step_idtry:LOG.info(- "Script trying to fallback to AI run",+ "Script block failed, checking AI fallback",cache_key=cache_key,+ block_type=block_type.value if hasattr(block_type, "value") else str(block_type),+ error=str(error) if error else None,organization_id=organization_id,- workflow_id=workflow_id,workflow_run_id=workflow_run_id,- task_id=task_id,- step_id=script_step_id,)# 1. fail the previous stepprevious_step = await app.DATABASE.update_step(@@ -1125,8 +1124,8 @@ async def _fallback_to_ai_run()if not effective_ai_fallback:LOG.info(- "AI fallback is not enabled for the workflow",- workflow_id=workflow_id,+ "AI fallback disabled — script failure will not be retried by agent",+ cache_key=cache_key,workflow_permanent_id=workflow_permanent_id,workflow_run_id=workflow_run_id,)@@ -1278,8 +1277,9 @@ async def _fallback_to_ai_run(parameter_type=ParameterType.OUTPUT,)LOG.info(- "Script starting to fallback to AI run",+ "Falling back to agent for block — script failed, AI will re-run",cache_key=cache_key,+ block_type=block_type.value if hasattr(block_type, "value") else str(block_type),organization_id=organization_id,workflow_id=workflow_id,workflow_run_id=workflow_run_id,