From 4c0330c7f0b2a0d4069405d2171910c96270772e Mon Sep 17 00:00:00 2001 From: shaohuzhang1 Date: Tue, 22 Sep 2026 14:42:34 +0800 Subject: [PATCH] fix: Connection closed during tool invocation. --- apps/application/flow/tools.py | 2 ++ 1 file changed, 2 insertions(+) diff --git a/apps/application/flow/tools.py b/apps/application/flow/tools.py index 504c5f45494..f1c678a5f8c 100644 --- a/apps/application/flow/tools.py +++ b/apps/application/flow/tools.py @@ -732,6 +732,8 @@ def get_real_error(exc): async def save_tool_record(tool_id, tool_info, tool_result, source_id, source_type): + from django.db import close_old_connections + await sync_to_async(close_old_connections)() tool = await sync_to_async(lambda: QuerySet(Tool).filter(id=tool_id).first())() tool_info["icon"] = tool.icon tool_record = ToolRecord(