see i want that my agent will hangup call
so to hangup call this function is not working
async def hangup_call(self) -> Dict[str, Any]:
"""Properly hang up the call by deleting the LiveKit room"""
if not self.session_manager:
return {"success": False, "message": "Session unavailable"}
booking = self.session.userdata.booking
room_name = self.session_manager.room.name
logger.info(
f"📞 Initiating room deletion hangup for booking {booking.booking_id} "
f"(room: {room_name})"
)
try:
# ✅ POSITIONAL ARGUMENT (required by your SDK)
await self.session_manager.ctx.api.room.delete_room(room_name)
logger.info(f"✅ Room {room_name} deleted - call ended")
if booking.booking_id:
await db_manager.mark_call_ended(
booking.booking_id,
"NORMAL_COMPLETION"
)
await self.session.aclose()
return {"success": True, "message": "Call ended"}
except Exception as e:
logger.error(f"❌ Failed to delete room {room_name}: {e}")
# Fallback: still close agent session
try:
await self.session.aclose()
except Exception:
pass
return {"success": False, "error": str(e)}
it can't hangup