feat: 持久化会话节点结果与失败通知留痕
This commit is contained in:
@@ -1,3 +1,4 @@
|
||||
from django.utils import timezone
|
||||
from django.shortcuts import get_object_or_404, redirect, render
|
||||
|
||||
from agent_core.orchestrator import run_agent
|
||||
@@ -70,8 +71,10 @@ def detail(request, conversation_id: str):
|
||||
conversation_id=conversation.conversation_id,
|
||||
product_name=conversation.product_name,
|
||||
)
|
||||
_apply_agent_result_to_conversation(conversation, result)
|
||||
_persist_notification_records(result)
|
||||
active_node = "risk"
|
||||
conversation.refresh_from_db()
|
||||
workspace_summary = _build_workspace_summary(conversation, batch)
|
||||
|
||||
return render(
|
||||
@@ -129,3 +132,25 @@ def _build_workspace_summary(conversation: Conversation, batch: SubmissionBatch
|
||||
"file_count": batch.file_count if batch else 0,
|
||||
"page_count": batch.page_count if batch else 0,
|
||||
}
|
||||
|
||||
|
||||
def _apply_agent_result_to_conversation(conversation: Conversation, result: AgentResult) -> None:
|
||||
conversation.task_status = result.status
|
||||
if result.node_results:
|
||||
conversation.node_results = result.node_results
|
||||
conversation.latest_summary = {
|
||||
"answer": result.answer,
|
||||
"status": result.status,
|
||||
"error": result.error,
|
||||
"notification_payload": result.notification_payload,
|
||||
}
|
||||
conversation.last_run_at = timezone.now()
|
||||
conversation.save(
|
||||
update_fields=[
|
||||
"task_status",
|
||||
"node_results",
|
||||
"latest_summary",
|
||||
"last_run_at",
|
||||
"updated_at",
|
||||
]
|
||||
)
|
||||
|
||||
Reference in New Issue
Block a user