agentscope-ai / agentscope-ai/QwenPaw

[Bug]: auto_memory_interval 写入记忆文件但不同步向量索引,/new 后新会话 memory_search 搜不到

Open
#4,220 4 comments 0 reactions 1 assignee Claimed by @jinliyl View on GitHub
Dominant language
Python
Stars
34.9k
Forks
3.1k
Avg merge
1d 15h
Merged PRs (30d)
225

Description

## [Bug]: auto_memory_interval 写入记忆文件但不同步向量索引,/new 后新会话 memory_search 搜不到

**QwenPaw 版本:** v1.1.6

### 描述

开启 `auto_memory_interval: 3` 后,auto-memory 后台任务会在每 3 条用户消息后调用 Summarizer 将对话摘要写入 `memory/YYYY-MM-DD.md`。文件确实写入了,但 `memory_search` 在新会话中始终返回空结果——**向量索引没有被同步更新**。

**Expected:** auto_memory 写入后,新会话的 `memory_search` 能立即搜到刚记录的记忆。

**Actual:** 文件存在于磁盘,但 `memory_search` 返回空,需等到当晚 23:00 Memory Dream 运行后才能搜到。

### 复现步骤

1. 在 `agent.json` 中配置 `running.reme_light_memory_config.auto_memory_interval: 3`
2. 正常对话,发送至少 3 条用户消息,触发 auto_memory
3. 使用 `/new` 启动新会话
4. 在新会话中调用 `memory_search` 搜索刚聊过的内容
5. **结果:** 返回空结果

### 日志证据

```
# auto_memory 任务确实完成了
2026-05-11 21:49:44 | INFO | Summary task task_44 started
2026-05-11 21:50:30 | INFO | Summary task task_44 completed
# 后续 task_45~50 均完成
```

### 根因分析

auto_memory 调用链:
```
post_reply_hook → add_summarize_task → ReMeLight.summary_memory()
→ Summarizer (ReActAgent)
→ write_file/edit_file 写入 memory/2026-05-11.md ✅(数据落盘)
```

`Summarizer` 使用的是独立的 `FileIO.write_file` 工具直接写磁盘文件,但写完后没有调用 `LocalFileStore.upsert_file()` 来更新内存中的向量索引(`_chunks` 字典)。`LocalFileStore.upsert_file` 负责生成 chunks embedding 并注册到索引中,而 `Summarizer` 完全跳过了这一步。

对比之下,`ReMeLightMemoryManager.dream()`(每晚 23:00 的 Memory Dream)走的是另一套 ReActAgent prompt,同样写磁盘,但跨过了 23:00 的时间窗口后,索引自然不过期。而 `auto_memory_interval` 在会话生命周期内写入的内容,索引不会随之更新。

### 建议修复方向

在 `Summarizer` 完成文件写入后,显式调用 `LocalFileStore.upsert_file()` 更新向量索引,而非依赖文件监听器被动同步。

具体位置:`reme/memory/file_based/components/summarizer.py` 中 `Summarizer.execute()` 的末尾,在 Remy ReActAgent 完成文件写入后,读取目标文件内容,调用 `file_store.upsert_file()` 更新 chunks。

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.