re-enable post action script gen when there's no published script (#3583)

This commit is contained in:
Shuchang Zheng
2025-10-01 15:05:53 -07:00
committed by GitHub
parent 4a2b091226
commit fae8e8f089
3 changed files with 16 additions and 7 deletions

View File

@@ -20,6 +20,7 @@ from skyvern.forge.sdk.schemas.organizations import Organization
from skyvern.forge.sdk.schemas.tasks import Task, TaskStatus
from skyvern.forge.sdk.trace import TraceManager
from skyvern.forge.sdk.workflow.models.block import BlockTypeVar
from skyvern.services import workflow_script_service
from skyvern.webeye.browser_factory import BrowserState
from skyvern.webeye.scraper.scraper import ELEMENT_NODE_ATTRIBUTES, CleanupElementTreeFunc, json_to_html
from 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
):
return
root_workflow_run_id = context.root_workflow_run_id
organization_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())

View File

@@ -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 = None
def __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})"

View File

@@ -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 parameters
workflow_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 instead
workflow_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_id
is_script_run = self.should_run_script(workflow, workflow_run)
if workflow_script and is_script_run:
LOG.info(