From 89b215627dff4a68a2f977e04eccc943a72a9fb1 Mon Sep 17 00:00:00 2001 From: Sharifajahan Shaik Date: Sat, 16 May 2026 15:55:19 +0530 Subject: [PATCH] fix: set in-memory outcome to prevent BUSY default in direct mode --- app/ai/voice/agents/breeze_buddy/template/hooks.py | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/app/ai/voice/agents/breeze_buddy/template/hooks.py b/app/ai/voice/agents/breeze_buddy/template/hooks.py index 501977ed..f04907d8 100644 --- a/app/ai/voice/agents/breeze_buddy/template/hooks.py +++ b/app/ai/voice/agents/breeze_buddy/template/hooks.py @@ -244,6 +244,12 @@ async def execute( ) outcome = "TRANSFERRED" + # Set in-memory outcome AFTER transfer override but BEFORE the + # async DB write. This prevents a race condition in Direct Mode + # where end_conversation_global checks context.lead.outcome and + # defaults to BUSY because the async DB write hasn't completed yet. + context.lead.outcome = outcome + # Update lead in database with outcome logger.info( f"Updating lead {context.lead.id} in database with outcome: {outcome}, "