From ccb1c269e8d803992484eb948572e7ee0bd6f0ce Mon Sep 17 00:00:00 2001 From: Womsxd <45663319+Womsxd@users.noreply.github.com> Date: Sun, 28 Sep 2025 15:40:06 +0800 Subject: [PATCH] fix: Handling Null Values in SQL Execution Results (#10332) ### What problem does this PR solve? Close #10324 The agent reported an error "undefined" after using the ExeSql tool. ### Type of change - [x] Bug Fix (non-breaking change which fixes an issue) now: img --- agent/tools/exesql.py | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/agent/tools/exesql.py b/agent/tools/exesql.py index 464f06095..2e1cc24bf 100644 --- a/agent/tools/exesql.py +++ b/agent/tools/exesql.py @@ -162,6 +162,8 @@ class ExeSQL(ToolBase, ABC): if pd.api.types.is_datetime64_any_dtype(df[col]): df[col] = df[col].dt.strftime("%Y-%m-%d") + df = df.where(pd.notnull(df), None) + sql_res.append(convert_decimals(df.to_dict(orient="records"))) formalized_content.append(df.to_markdown(index=False, floatfmt=".6f")) @@ -197,6 +199,8 @@ class ExeSQL(ToolBase, ABC): if pd.api.types.is_datetime64_any_dtype(single_res[col]): single_res[col] = single_res[col].dt.strftime('%Y-%m-%d') + single_res = single_res.where(pd.notnull(single_res), None) + sql_res.append(convert_decimals(single_res.to_dict(orient='records'))) formalized_content.append(single_res.to_markdown(index=False, floatfmt=".6f"))