fix: ignore completed call status

This commit is contained in:
Sabiha Khan 2026-02-14 00:03:33 +05:30
parent 51adfdda66
commit e485f649bd
7 changed files with 168 additions and 96 deletions

View file

@ -1742,12 +1742,11 @@ async def complete_transfer_function_call(tool_call_id: str, request: Request):
# Note: All transfer coordination now handled via Redis events
# If this is a "completed" status but we already handled the success case via answer webhook,
# we should still publish the COMPLETED event but not override previous results
# Skip "completed" status to avoid overriding successful transfer results
# The "answered" status already handled the success case
if call_status == "completed":
# Check if we already published an ANSWERED event
logger.info(f"Processing 'completed' status for {tool_call_id}")
# We'll still publish COMPLETED event but with different handling
logger.info(f"Ignoring 'completed' status for {tool_call_id} to avoid overriding previous results")
return {"status": "ignored", "reason": "completed_status_filtered"}
# Import required event classes
from api.services.telephony.transfer_event_protocol import TransferEvent, TransferEventType
@ -1803,15 +1802,6 @@ async def complete_transfer_function_call(tool_call_id: str, request: Request):
"call_sid": call_sid,
"end_call": True
}
elif call_status == "completed":
# Call completed successfully
result = {
"status": "completed",
"message": "Your call has been completed successfully.",
"action": "transfer_completed",
"call_sid": call_sid,
"end_call": True # End call normally
}
else:
# Intermediate status (ringing, in-progress, etc.), don't complete yet
logger.info(f"Received intermediate status {call_status}, waiting for final status")

View file

@ -10,7 +10,7 @@ import aiohttp
from fastapi import HTTPException
from loguru import logger
from twilio.request_validator import RequestValidator
from pipecat.utils.context import set_current_call_sid
from pipecat.utils.run_context import set_current_call_sid
from api.enums import WorkflowRunMode
from api.services.telephony.base import (

View file

@ -11,6 +11,7 @@ import re
from typing import TYPE_CHECKING, Any, Optional
import aiohttp
import httpx
from loguru import logger
from api.db import db_client
@ -319,7 +320,7 @@ class CustomToolManager:
await self._engine.task.queue_frame(TTSSpeakFrame(custom_message))
# Get original call information from Pipecat context
from pipecat.utils.context import get_current_call_sid
from pipecat.utils.run_context import get_current_call_sid
original_call_sid = get_current_call_sid()
caller_number = None # Skip caller number for now as requested
@ -352,7 +353,6 @@ class CustomToolManager:
}
# Initialize Redis-based transfer coordination
import httpx
import time
# Get backend endpoint URL

@ -1 +1 @@
Subproject commit e180bd3c2abc3cebbdf5e2d7955d9928cca5d219
Subproject commit 0019ba697e4d90dbe70902f1e7df751323960d53

4
ui/package-lock.json generated
View file

@ -1,12 +1,12 @@
{
"name": "ui",
"version": "1.11.2",
"version": "1.13.0",
"lockfileVersion": 3,
"requires": true,
"packages": {
"": {
"name": "ui",
"version": "1.11.2",
"version": "1.13.0",
"dependencies": {
"@dagrejs/dagre": "^1.1.4",
"@hey-api/client-fetch": "^0.10.0",

File diff suppressed because one or more lines are too long

View file

@ -675,27 +675,6 @@ export type LoadTestStatsResponse = {
}>;
};
/**
* Request schema for order status lookup.
*/
export type OrderRequest = {
order_id: string;
};
/**
* Response schema for order status.
*/
export type OrderResponse = {
order_id: string;
status: string;
refund_status: string;
amount: number;
currency: string;
created_at: string;
refunded_at: string | null;
refund_amount: number | null;
};
export type PresignedUploadUrlRequest = {
/**
* CSV filename
@ -907,9 +886,12 @@ export type TransferCallConfig = {
*/
export type TransferCallRequest = {
destination: string;
organization_id: number;
timeout?: number | null;
tool_call_id?: string | null;
tool_uuid?: string | null;
original_call_sid?: string | null;
caller_number?: string | null;
};
/**
@ -1602,6 +1584,112 @@ export type HandleCloudonixCdrApiV1TelephonyCloudonixCdrPostResponses = {
200: unknown;
};
export type InitiateCallTransferApiV1TelephonyCallTransferPostData = {
body: TransferCallRequest;
path?: never;
query?: never;
url: '/api/v1/telephony/call-transfer';
};
export type InitiateCallTransferApiV1TelephonyCallTransferPostErrors = {
/**
* Not found
*/
404: unknown;
/**
* Validation Error
*/
422: HttpValidationError;
};
export type InitiateCallTransferApiV1TelephonyCallTransferPostError = InitiateCallTransferApiV1TelephonyCallTransferPostErrors[keyof InitiateCallTransferApiV1TelephonyCallTransferPostErrors];
export type InitiateCallTransferApiV1TelephonyCallTransferPostResponses = {
/**
* Successful Response
*/
200: unknown;
};
export type HandleTransferCallAnsweredApiV1TelephonyTransferCallHandlerToolCallIdPostData = {
body?: never;
path: {
tool_call_id: string;
};
query?: never;
url: '/api/v1/telephony/transfer-call-handler/{tool_call_id}';
};
export type HandleTransferCallAnsweredApiV1TelephonyTransferCallHandlerToolCallIdPostErrors = {
/**
* Not found
*/
404: unknown;
/**
* Validation Error
*/
422: HttpValidationError;
};
export type HandleTransferCallAnsweredApiV1TelephonyTransferCallHandlerToolCallIdPostError = HandleTransferCallAnsweredApiV1TelephonyTransferCallHandlerToolCallIdPostErrors[keyof HandleTransferCallAnsweredApiV1TelephonyTransferCallHandlerToolCallIdPostErrors];
export type HandleTransferCallAnsweredApiV1TelephonyTransferCallHandlerToolCallIdPostResponses = {
/**
* Successful Response
*/
200: unknown;
};
export type CompleteTransferFunctionCallApiV1TelephonyTransferResultToolCallIdPostData = {
body?: never;
path: {
tool_call_id: string;
};
query?: never;
url: '/api/v1/telephony/transfer-result/{tool_call_id}';
};
export type CompleteTransferFunctionCallApiV1TelephonyTransferResultToolCallIdPostErrors = {
/**
* Not found
*/
404: unknown;
/**
* Validation Error
*/
422: HttpValidationError;
};
export type CompleteTransferFunctionCallApiV1TelephonyTransferResultToolCallIdPostError = CompleteTransferFunctionCallApiV1TelephonyTransferResultToolCallIdPostErrors[keyof CompleteTransferFunctionCallApiV1TelephonyTransferResultToolCallIdPostErrors];
export type CompleteTransferFunctionCallApiV1TelephonyTransferResultToolCallIdPostResponses = {
/**
* Successful Response
*/
200: unknown;
};
export type RegisterTransferToolCallApiV1TelephonyRegisterTransferToolCallPostData = {
body?: never;
path?: never;
query?: never;
url: '/api/v1/telephony/register-transfer-tool-call';
};
export type RegisterTransferToolCallApiV1TelephonyRegisterTransferToolCallPostErrors = {
/**
* Not found
*/
404: unknown;
};
export type RegisterTransferToolCallApiV1TelephonyRegisterTransferToolCallPostResponses = {
/**
* Successful Response
*/
200: unknown;
};
export type ImpersonateApiV1SuperuserImpersonatePostData = {
body: ImpersonateRequest;
headers?: {
@ -4869,35 +4957,6 @@ export type SearchChunksApiV1KnowledgeBaseSearchPostResponses = {
export type SearchChunksApiV1KnowledgeBaseSearchPostResponse = SearchChunksApiV1KnowledgeBaseSearchPostResponses[keyof SearchChunksApiV1KnowledgeBaseSearchPostResponses];
export type GetOrderStatusApiV1OrderStatusPostData = {
body: OrderRequest;
path?: never;
query?: never;
url: '/api/v1/order/status';
};
export type GetOrderStatusApiV1OrderStatusPostErrors = {
/**
* Not found
*/
404: unknown;
/**
* Validation Error
*/
422: HttpValidationError;
};
export type GetOrderStatusApiV1OrderStatusPostError = GetOrderStatusApiV1OrderStatusPostErrors[keyof GetOrderStatusApiV1OrderStatusPostErrors];
export type GetOrderStatusApiV1OrderStatusPostResponses = {
/**
* Successful Response
*/
200: OrderResponse;
};
export type GetOrderStatusApiV1OrderStatusPostResponse = GetOrderStatusApiV1OrderStatusPostResponses[keyof GetOrderStatusApiV1OrderStatusPostResponses];
export type HealthApiV1HealthGetData = {
body?: never;
path?: never;