From 4544aa86f769e46273852480faefc72dc234fb9c Mon Sep 17 00:00:00 2001 From: hzt <3061613175@qq.com> Date: Fri, 20 Feb 2026 12:22:16 +0800 Subject: [PATCH] fix: prevent race condition in ChainlitDataLayer step content Convert empty string input/output to NULL before persisting to database, so that the existing COALESCE logic in the upsert query correctly preserves content when the initial send() (with empty output) commits after update() (with real output). Fixes #2789 --- backend/chainlit/data/chainlit_data_layer.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/backend/chainlit/data/chainlit_data_layer.py b/backend/chainlit/data/chainlit_data_layer.py index d2fb2d9f62..438fa4c40d 100644 --- a/backend/chainlit/data/chainlit_data_layer.py +++ b/backend/chainlit/data/chainlit_data_layer.py @@ -378,10 +378,10 @@ async def create_step(self, step_dict: StepDict): "id": step_dict["id"], "thread_id": step_dict.get("threadId"), "parent_id": step_dict.get("parentId"), - "input": step_dict.get("input"), + "input": step_dict.get("input") or None, "metadata": json.dumps(step_dict.get("metadata", {})), "name": step_dict.get("name"), - "output": step_dict.get("output"), + "output": step_dict.get("output") or None, "type": step_dict["type"], "start_time": timestamp, "end_time": timestamp,