Fix: persist runs by passing asked_question_ids
Browse files
backend/api/conversation_service.py
CHANGED
|
@@ -510,7 +510,12 @@ class ConversationService:
|
|
| 510 |
chat_info.status = ConversationStatus.COMPLETED
|
| 511 |
await self._send_status_update(conversation_id, ConversationStatus.COMPLETED)
|
| 512 |
|
| 513 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 514 |
|
| 515 |
self.active_human_chats.pop(conversation_id, None)
|
| 516 |
self.transcripts.pop(conversation_id, None)
|
|
@@ -931,7 +936,12 @@ class ConversationService:
|
|
| 931 |
|
| 932 |
# Trigger resource-agent analysis only for natural completion (not user stop)
|
| 933 |
if not conv_info.stop_requested:
|
| 934 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 935 |
|
| 936 |
# End of lifecycle (MVP): remove completed conversation state
|
| 937 |
self.active_conversations.pop(conversation_id, None)
|
|
@@ -941,7 +951,7 @@ class ConversationService:
|
|
| 941 |
if conversation_id not in self.active_conversations:
|
| 942 |
self.transcripts.pop(conversation_id, None)
|
| 943 |
|
| 944 |
-
async def _run_resource_agent(self, conversation_id: str):
|
| 945 |
"""Run post-conversation resource agent analysis and broadcast results."""
|
| 946 |
transcript = self.transcripts.get(conversation_id, [])
|
| 947 |
if not transcript:
|
|
@@ -999,7 +1009,7 @@ class ConversationService:
|
|
| 999 |
"patient_prompt_addition": getattr(conv_info, "patient_prompt_addition", None),
|
| 1000 |
"surveyor_attributes": getattr(conv_info, "surveyor_attributes", None),
|
| 1001 |
"surveyor_question_bank": getattr(conv_info, "surveyor_question_bank", None),
|
| 1002 |
-
"asked_question_ids":
|
| 1003 |
},
|
| 1004 |
}
|
| 1005 |
|
|
|
|
| 510 |
chat_info.status = ConversationStatus.COMPLETED
|
| 511 |
await self._send_status_update(conversation_id, ConversationStatus.COMPLETED)
|
| 512 |
|
| 513 |
+
asked_ids = None
|
| 514 |
+
try:
|
| 515 |
+
asked_ids = list(getattr(chat_info, "asked_question_ids", None) or [])
|
| 516 |
+
except Exception:
|
| 517 |
+
asked_ids = None
|
| 518 |
+
await self._run_resource_agent(conversation_id, asked_question_ids=asked_ids)
|
| 519 |
|
| 520 |
self.active_human_chats.pop(conversation_id, None)
|
| 521 |
self.transcripts.pop(conversation_id, None)
|
|
|
|
| 936 |
|
| 937 |
# Trigger resource-agent analysis only for natural completion (not user stop)
|
| 938 |
if not conv_info.stop_requested:
|
| 939 |
+
asked_ids = None
|
| 940 |
+
try:
|
| 941 |
+
asked_ids = list(getattr(manager, "asked_question_ids", None) or [])
|
| 942 |
+
except Exception:
|
| 943 |
+
asked_ids = None
|
| 944 |
+
await self._run_resource_agent(conversation_id, asked_question_ids=asked_ids)
|
| 945 |
|
| 946 |
# End of lifecycle (MVP): remove completed conversation state
|
| 947 |
self.active_conversations.pop(conversation_id, None)
|
|
|
|
| 951 |
if conversation_id not in self.active_conversations:
|
| 952 |
self.transcripts.pop(conversation_id, None)
|
| 953 |
|
| 954 |
+
async def _run_resource_agent(self, conversation_id: str, *, asked_question_ids: Optional[List[str]] = None):
|
| 955 |
"""Run post-conversation resource agent analysis and broadcast results."""
|
| 956 |
transcript = self.transcripts.get(conversation_id, [])
|
| 957 |
if not transcript:
|
|
|
|
| 1009 |
"patient_prompt_addition": getattr(conv_info, "patient_prompt_addition", None),
|
| 1010 |
"surveyor_attributes": getattr(conv_info, "surveyor_attributes", None),
|
| 1011 |
"surveyor_question_bank": getattr(conv_info, "surveyor_question_bank", None),
|
| 1012 |
+
"asked_question_ids": asked_question_ids,
|
| 1013 |
},
|
| 1014 |
}
|
| 1015 |
|