From bdaca5994a1e4da6ebf57c1bd8c3595b3916396f Mon Sep 17 00:00:00 2001 From: Jonathan Dobson Date: Thu, 17 Jul 2025 16:33:06 -0400 Subject: [PATCH] release session in main cancel routine (#2978) --- skyvern/forge/sdk/routes/agent_protocol.py | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/skyvern/forge/sdk/routes/agent_protocol.py b/skyvern/forge/sdk/routes/agent_protocol.py index 8c337192..e60f2450 100644 --- a/skyvern/forge/sdk/routes/agent_protocol.py +++ b/skyvern/forge/sdk/routes/agent_protocol.py @@ -1059,6 +1059,9 @@ async def _cancel_workflow_run(workflow_run_id: str, organization_id: str, x_api detail=f"Workflow run not found {workflow_run_id}", ) + if workflow_run.browser_session_id: + await app.PERSISTENT_SESSIONS_MANAGER.release_browser_session(workflow_run.browser_session_id, organization_id) + # get all the child workflow runs and cancel them child_workflow_runs = await app.DATABASE.get_workflow_runs_by_parent_workflow_run_id( parent_workflow_run_id=workflow_run_id, @@ -1108,8 +1111,6 @@ async def cancel_persistent_browser_session_workflow_run( current_org: Organization = Depends(org_auth_service.get_current_org), x_api_key: Annotated[str | None, Header()] = None, ) -> None: - await app.PERSISTENT_SESSIONS_MANAGER.release_browser_session(browser_session_id, current_org.organization_id) - await _cancel_workflow_run(workflow_run_id, current_org.organization_id, x_api_key)