From d58ec739767108aad73a28f343c5d7d044090fad Mon Sep 17 00:00:00 2001 From: Anibal Angulo Date: Fri, 20 Feb 2026 14:30:45 +0000 Subject: [PATCH] Fix critical bugs --- pyproject.toml | 2 +- src/capa_de_integracion/services/conversation.py | 5 +++-- src/capa_de_integracion/services/notifications.py | 9 +++++++-- 3 files changed, 11 insertions(+), 5 deletions(-) diff --git a/pyproject.toml b/pyproject.toml index 4bcd026..ff867fe 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -73,7 +73,7 @@ filterwarnings = [ ] env = [ - "FIRESTORE_EMULATOR_HOST=[::1]:8911", + "FIRESTORE_EMULATOR_HOST=[::1]:8469", "GCP_PROJECT_ID=test-project", "GCP_LOCATION=us-central1", "GCP_FIRESTORE_DATABASE_ID=(default)", diff --git a/src/capa_de_integracion/services/conversation.py b/src/capa_de_integracion/services/conversation.py index 007fec4..cc508af 100644 --- a/src/capa_de_integracion/services/conversation.py +++ b/src/capa_de_integracion/services/conversation.py @@ -370,12 +370,13 @@ class ConversationManagerService: logger.info("Matched quick reply: %s", pregunta.titulo) break - # If no match, use first question as default or delegate to normal flow + # If no match, delegate to normal flow if not matched_answer: logger.warning( - "No matching quick reply found for message: '%s'.", + "No matching quick reply found for message: '%s'. Falling back to RAG.", request.mensaje, ) + return None # Create response with the matched quick reply answer return DetectIntentResponse( diff --git a/src/capa_de_integracion/services/notifications.py b/src/capa_de_integracion/services/notifications.py index 6bbee00..d3652fe 100644 --- a/src/capa_de_integracion/services/notifications.py +++ b/src/capa_de_integracion/services/notifications.py @@ -17,6 +17,9 @@ logger = logging.getLogger(__name__) PREFIX_PO_PARAM = "notification_po_" +# Keep references to background tasks to prevent garbage collection +_background_tasks: set[asyncio.Task] = set() + class NotificationManagerService: """Manages notification processing and integration with conversations. @@ -127,6 +130,8 @@ class NotificationManagerService: ) # Fire and forget - don't await - _task = asyncio.create_task(save_notification_to_firestore()) + task = asyncio.create_task(save_notification_to_firestore()) # Store reference to prevent premature garbage collection - del _task + _background_tasks.add(task) + # Remove from set when done to prevent memory leak + task.add_done_callback(_background_tasks.discard)