Automate browser based workflows with AI
Python aiapiautomationbrowserbrowser-automationcomputergptllmplaywrightpowerautomatepuppeteerpythonrpaseleniumvisionworkflow
re-enable post action script gen when there's no published script (#3583)
Shuchang Zhengfae8e8f08946
diff --git a/skyvern/forge/agent_functions.py b/skyvern/forge/agent_functions.pyindex b4faace6e..d4c2c88f1 100644--- a/skyvern/forge/agent_functions.py+++ b/skyvern/forge/agent_functions.py@@ -20,6 +20,7 @@ from skyvern.forge.sdk.schemas.organizations import Organizationfrom skyvern.forge.sdk.schemas.tasks import Task, TaskStatusfrom skyvern.forge.sdk.trace import TraceManagerfrom skyvern.forge.sdk.workflow.models.block import BlockTypeVar+from skyvern.services import workflow_script_servicefrom skyvern.webeye.browser_factory import BrowserStatefrom skyvern.webeye.scraper.scraper import ELEMENT_NODE_ATTRIBUTES, CleanupElementTreeFunc, json_to_htmlfrom skyvern.webeye.utils.dom import SkyvernElement@@ -621,7 +622,12 @@ class AgentFunction:If this is a workflow running environment, generate the"""context = skyvern_context.current()- if not context or not context.root_workflow_run_id or not context.organization_id:+ if (+ not context+ or not context.root_workflow_run_id+ or not context.organization_id+ or context.published_workflow_script_id+ ):returnroot_workflow_run_id = context.root_workflow_run_idorganization_id = context.organization_id@@ -640,11 +646,11 @@ class AgentFunction:root_workflow_run_id=context.root_workflow_run_id,organization_id=context.organization_id,)- # NOTE(jdo): we are commenting this out for now as it is causing issues with workflow runs- # await workflow_script_service.generate_or_update_pending_workflow_script(- # workflow_run=workflow_run,- # workflow=workflow,- # )++ await workflow_script_service.generate_or_update_pending_workflow_script(+ workflow_run=workflow_run,+ workflow=workflow,+ )async def post_action_execution(self) -> None:asyncio.create_task(self._post_action_execution())diff --git a/skyvern/forge/sdk/core/skyvern_context.py b/skyvern/forge/sdk/core/skyvern_context.pyindex 40f0758d2..7cf3ed3ce 100644--- a/skyvern/forge/sdk/core/skyvern_context.py+++ b/skyvern/forge/sdk/core/skyvern_context.py@@ -48,6 +48,7 @@ class SkyvernContext:Example output value:{"loop_value": "str", "output_parameter": "the key of the parameter", "output_value": Any}"""+ published_workflow_script_id: str | None = Nonedef __repr__(self) -> str:return f"SkyvernContext(request_id={self.request_id}, organization_id={self.organization_id}, task_id={self.task_id}, step_id={self.step_id}, workflow_id={self.workflow_id}, workflow_run_id={self.workflow_run_id}, task_v2_id={self.task_v2_id}, max_steps_override={self.max_steps_override}, run_id={self.run_id})"diff --git a/skyvern/forge/sdk/workflow/service.py b/skyvern/forge/sdk/workflow/service.pyindex cda8334e1..07fc4886d 100644--- a/skyvern/forge/sdk/workflow/service.py+++ b/skyvern/forge/sdk/workflow/service.py@@ -337,7 +337,6 @@ class WorkflowService:workflow_run = await self.get_workflow_run(workflow_run_id=workflow_run_id, organization_id=organization_id)workflow = await self.get_workflow_by_permanent_id(workflow_permanent_id=workflow_run.workflow_permanent_id)close_browser_on_completion = browser_session_id is None and not workflow_run.browser_address- skyvern_context.current()# Set workflow run status to running, create workflow run parametersworkflow_run = await self.mark_workflow_run_as_running(workflow_run_id=workflow_run_id)@@ -407,6 +406,9 @@ class WorkflowService:# Check if there's a related workflow script that should be used insteadworkflow_script, _ = await workflow_script_service.get_workflow_script(workflow, workflow_run, block_labels)+ current_context = skyvern_context.current()+ if workflow_script and current_context:+ current_context.published_workflow_script_id = workflow_script.script_idis_script_run = self.should_run_script(workflow, workflow_run)if workflow_script and is_script_run:LOG.info(