refactor(memory): insert new metadata values at list head for recency ordering
Change list.append() to list.insert(0, ...) in extract_user_metadata_task so that newly extracted user metadata values appear at the front of each field list, maintaining a newest-first ordering.
This commit is contained in:
@@ -3160,7 +3160,8 @@ def extract_user_metadata_task(
|
||||
|
||||
if action == "set":
|
||||
if value not in current_list:
|
||||
current_list.append(value)
|
||||
# 新值插入列表头部,保证按时间从新到旧排序
|
||||
current_list.insert(0, value)
|
||||
target[leaf] = current_list
|
||||
logger.info(f"[CELERY METADATA] set {field_path} = {value}")
|
||||
|
||||
@@ -3223,7 +3224,8 @@ def extract_user_metadata_task(
|
||||
leaf = parts[-1]
|
||||
current_list = target.get(leaf, [])
|
||||
if change.value not in current_list:
|
||||
current_list.append(change.value)
|
||||
# 新值插入列表头部,保证按时间从新到旧排序
|
||||
current_list.insert(0, change.value)
|
||||
target[leaf] = current_list
|
||||
|
||||
if first_alias or initial_meta:
|
||||
|
||||
Reference in New Issue
Block a user