fix: handle delayed transcription in ExternalTurnStopStrategy

This commit is contained in:
Abhishek Kumar 2026-03-05 19:21:05 +05:30
parent 6fcfe105f2
commit 77a55fcfe3
3 changed files with 14 additions and 17 deletions

View file

@ -747,11 +747,6 @@ async def _process_status_update(workflow_run_id: int, status: StatusCallbackReq
logs={"telephony_status_callbacks": telephony_callback_logs},
)
# The workflow run state is already marked as completed from either status-update
# callbacks or CDR update callbacks. Lets skip processing.
if workflow_run.state == WorkflowRunState.COMPLETED.value:
return
# Handle call completion - make these updates idempotent - i.e
# they should handle multiple API calls (one due to status update,
# and other due to CDR updates.)
@ -768,11 +763,12 @@ async def _process_status_update(workflow_run_id: int, status: StatusCallbackReq
)
# Mark workflow run as completed
await db_client.update_workflow_run(
run_id=workflow_run_id,
is_completed=True,
state=WorkflowRunState.COMPLETED.value,
)
if workflow_run.state != WorkflowRunState.COMPLETED.value:
await db_client.update_workflow_run(
run_id=workflow_run_id,
is_completed=True,
state=WorkflowRunState.COMPLETED.value,
)
elif status.status in ["failed", "busy", "no-answer", "canceled", "error"]:
logger.warning(
@ -813,6 +809,10 @@ async def _process_status_update(workflow_run_id: int, status: StatusCallbackReq
state=WorkflowRunState.COMPLETED.value,
gathered_context={"call_tags": call_tags},
)
else:
logger.warning(
f"[run {workflow_run_id}] Unexpected status update: {status.status}"
)
@router.post("/vonage/events/{workflow_run_id}")