From 41801ad2b814fb747525bf9624ddb8d70bd9064e Mon Sep 17 00:00:00 2001 From: euvre <93761161+euvre@users.noreply.github.com> Date: Tue, 7 Jul 2026 19:34:51 +0800 Subject: [PATCH] fix: prevent memory name from auto-appending (1) on description update (#16714) --- api/db/services/memory_service.py | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/api/db/services/memory_service.py b/api/db/services/memory_service.py index 1bb16cf79..97e5007d8 100644 --- a/api/db/services/memory_service.py +++ b/api/db/services/memory_service.py @@ -150,7 +150,9 @@ class MemoryService(CommonService): if "memory_type" in update_dict and isinstance(update_dict["memory_type"], list): update_dict["memory_type"] = calculate_memory_type(update_dict["memory_type"]) if "name" in update_dict: - update_dict["name"] = duplicate_name(cls.query, name=update_dict["name"], tenant_id=tenant_id) + existing = cls.model.select().where((cls.model.id == memory_id) & (cls.model.tenant_id == tenant_id)).first() + if not existing or existing.name != update_dict["name"]: + update_dict["name"] = duplicate_name(cls.query, name=update_dict["name"], tenant_id=tenant_id) update_dict.update({"update_time": current_timestamp(), "update_date": get_format_time()}) return cls.model.update(update_dict).where(cls.model.id == memory_id).execute()