From 93371cd0cd2493f6867c65a714720309e20c8e73 Mon Sep 17 00:00:00 2001 From: Shuchang Zheng Date: Thu, 3 Apr 2025 21:51:38 -0400 Subject: [PATCH] handle unexpected llm error in task v2 runner and clean up browser (#2100) --- skyvern/services/task_v2_service.py | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/skyvern/services/task_v2_service.py b/skyvern/services/task_v2_service.py index 2c1c808d..5090e7c2 100644 --- a/skyvern/services/task_v2_service.py +++ b/skyvern/services/task_v2_service.py @@ -278,6 +278,12 @@ async def run_task_v2( organization_id=organization_id, ) finally: + if task_v2.workflow_id and not workflow: + workflow = await app.WORKFLOW_SERVICE.get_workflow(task_v2.workflow_id, organization_id=organization_id) + if task_v2.workflow_run_id and not workflow_run: + workflow_run = await app.WORKFLOW_SERVICE.get_workflow_run( + task_v2.workflow_run_id, organization_id=organization_id + ) if workflow and workflow_run and workflow_run.parent_workflow_run_id is None: await app.WORKFLOW_SERVICE.clean_up_workflow( workflow=workflow,