Repository navigation
Commit 018c32a
committed
fix(scheduler): keep unrelated filtering for a single memory
`filter_unrelated_and_redundant_memories` returned early on
`len(memories) <= 1`, skipping both of the filtering steps it is responsible
for. That guard is correct for `filter_redundant_memories` — one memory cannot
be redundant with itself — but this method also removes memories that are
unrelated to the query history, and that check is per-memory: it applies just as
well to a list of one.
`filter_unrelated_memories`, which does only that step, has no such guard. So
the two paths disagreed on the same input: given one off-topic memory, the
unrelated-only filter dropped it while the combined filter kept it and never
consulted the LLM at all.
The log lines record the copy: the redundancy filter says "no redundancy to
filter" (accurate), while the combined one says "no filtering needed"
(not accurate — unrelated filtering was still needed). The guard was carried
over without widening its condition.
The prompt confirms the intent. MEMORY_COMBINED_FILTERING_PROMPT asks for two
steps, the first being "Unrelated Memory Removal ... Has no semantic connection
to any query in the history", which needs no second memory to be meaningful.
This runs on the working-memory replacement path
(`optimized_scheduler.replace_working_memory`), so a single unrelated memory
survived into working memory.
Drop the guard. The `not memories` and `not query_history` early returns are
untouched, and the LLM-failure path still conservatively keeps everything.1 parent 0f74774 commit 018c32a
2 files changed
Lines changed: 50 additions & 4 deletions
File tree
- src/memos/mem_scheduler/memory_manage_modules
- tests/mem_scheduler
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
234 | 234 | | |
235 | 235 | | |
236 | 236 | | |
237 | | - | |
238 | | - | |
239 | | - | |
240 | | - | |
241 | 237 | | |
242 | 238 | | |
243 | 239 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
360 | 360 | | |
361 | 361 | | |
362 | 362 | | |
| 363 | + | |
| 364 | + | |
| 365 | + | |
| 366 | + | |
| 367 | + | |
| 368 | + | |
| 369 | + | |
| 370 | + | |
| 371 | + | |
| 372 | + | |
| 373 | + | |
| 374 | + | |
| 375 | + | |
| 376 | + | |
| 377 | + | |
| 378 | + | |
| 379 | + | |
| 380 | + | |
| 381 | + | |
| 382 | + | |
| 383 | + | |
| 384 | + | |
| 385 | + | |
| 386 | + | |
| 387 | + | |
| 388 | + | |
| 389 | + | |
| 390 | + | |
| 391 | + | |
| 392 | + | |
| 393 | + | |
| 394 | + | |
| 395 | + | |
| 396 | + | |
| 397 | + | |
| 398 | + | |
| 399 | + | |
| 400 | + | |
| 401 | + | |
| 402 | + | |
| 403 | + | |
| 404 | + | |
| 405 | + | |
| 406 | + | |
| 407 | + | |
| 408 | + | |
| 409 | + | |
| 410 | + | |
| 411 | + | |
| 412 | + | |
0 commit comments