diff --git a/skyvern/core/script_generations/generate_script.py b/skyvern/core/script_generations/generate_script.py index 89712151..ad220eb9 100644 --- a/skyvern/core/script_generations/generate_script.py +++ b/skyvern/core/script_generations/generate_script.py @@ -1741,6 +1741,7 @@ async def generate_workflow_script_python_code( script_id=script_id, organization_id=organization_id, block_label=block_name, + update=pending, ) except Exception as e: LOG.error("Failed to create task_v2 script block", error=str(e), exc_info=True) @@ -1845,13 +1846,11 @@ async def create_or_update_script_block( block_code_bytes = block_code if isinstance(block_code, bytes) else block_code.encode("utf-8") try: # Step 3: Create script block in database - script_block = None - if update: - script_block = await app.DATABASE.get_script_block_by_label( - organization_id=organization_id, - script_revision_id=script_revision_id, - script_block_label=block_label, - ) + script_block = await app.DATABASE.get_script_block_by_label( + organization_id=organization_id, + script_revision_id=script_revision_id, + script_block_label=block_label, + ) if not script_block: script_block = await app.DATABASE.create_script_block( script_revision_id=script_revision_id, diff --git a/skyvern/forge/sdk/workflow/service.py b/skyvern/forge/sdk/workflow/service.py index ec29cde4..f94c24b9 100644 --- a/skyvern/forge/sdk/workflow/service.py +++ b/skyvern/forge/sdk/workflow/service.py @@ -249,6 +249,9 @@ class WorkflowService: ) context: skyvern_context.SkyvernContext | None = skyvern_context.current() current_run_id = context.run_id if context and context.run_id else workflow_run.workflow_run_id + root_workflow_run_id = ( + context.root_workflow_run_id if context and context.root_workflow_run_id else workflow_run.workflow_run_id + ) skyvern_context.set( SkyvernContext( organization_id=organization.organization_id, @@ -256,7 +259,7 @@ class WorkflowService: request_id=request_id, workflow_id=workflow_id, workflow_run_id=workflow_run.workflow_run_id, - root_workflow_run_id=workflow_run.workflow_run_id, + root_workflow_run_id=root_workflow_run_id, run_id=current_run_id, workflow_permanent_id=workflow_run.workflow_permanent_id, max_steps_override=max_steps_override,