From 0634aa13a1c7c15cf62859bec28228aea26ab1dd Mon Sep 17 00:00:00 2001 From: Sarah Wooders Date: Thu, 11 Dec 2025 19:59:26 -0800 Subject: [PATCH] fix: avoid holding sessions open (#6769) --- letta/services/step_manager.py | 30 ++++++++++++------------------ 1 file changed, 12 insertions(+), 18 deletions(-) diff --git a/letta/services/step_manager.py b/letta/services/step_manager.py index c64a1e08..605717eb 100644 --- a/letta/services/step_manager.py +++ b/letta/services/step_manager.py @@ -363,12 +363,10 @@ class StepManager: await session.commit() pydantic_step = step.to_pydantic() - - # Send webhook notification for step completion - webhook_service = WebhookService() - await webhook_service.notify_step_complete(step_id) - - return pydantic_step + # Send webhook notification for step completion outside the DB session + webhook_service = WebhookService() + await webhook_service.notify_step_complete(step_id) + return pydantic_step @enforce_types @trace_method @@ -416,12 +414,10 @@ class StepManager: await session.commit() pydantic_step = step.to_pydantic() - - # Send webhook notification for step completion - webhook_service = WebhookService() - await webhook_service.notify_step_complete(step_id) - - return pydantic_step + # Send webhook notification for step completion outside the DB session + webhook_service = WebhookService() + await webhook_service.notify_step_complete(step_id) + return pydantic_step @enforce_types @trace_method @@ -458,12 +454,10 @@ class StepManager: await session.commit() pydantic_step = step.to_pydantic() - - # Send webhook notification for step completion - webhook_service = WebhookService() - await webhook_service.notify_step_complete(step_id) - - return pydantic_step + # Send webhook notification for step completion outside the DB session + webhook_service = WebhookService() + await webhook_service.notify_step_complete(step_id) + return pydantic_step @enforce_types @trace_method