fix: retry voice turn once on Postgres deadlock instead of failing the call with a technical-error handoff
deploy / deploy (push) Successful in 34s
deploy / deploy (push) Successful in 34s
This commit is contained in:
@@ -1335,6 +1335,27 @@ def _process_voice_ai_turn_sync(
|
||||
payload: VoiceAITurnIn,
|
||||
*,
|
||||
auto_handoff: bool,
|
||||
) -> VoiceAITurnDecisionOut:
|
||||
last_exc: Exception | None = None
|
||||
for attempt in range(2):
|
||||
try:
|
||||
return _process_voice_ai_turn_sync_once(session_id, payload, auto_handoff=auto_handoff)
|
||||
except HTTPException as exc:
|
||||
if attempt == 0 and exc.status_code == 502 and "deadlock detected" in str(exc.detail).lower():
|
||||
logging.getLogger(__name__).warning("voice_turn_deadlock_retry session_id=%s", session_id)
|
||||
last_exc = exc
|
||||
continue
|
||||
raise
|
||||
if last_exc is not None:
|
||||
raise last_exc
|
||||
raise RuntimeError("unreachable")
|
||||
|
||||
|
||||
def _process_voice_ai_turn_sync_once(
|
||||
session_id: str,
|
||||
payload: VoiceAITurnIn,
|
||||
*,
|
||||
auto_handoff: bool,
|
||||
) -> VoiceAITurnDecisionOut:
|
||||
session = get_session()
|
||||
voice_session = None
|
||||
|
||||
Reference in New Issue
Block a user