Skip to content

fix(s09): re-locate the memory turn by identity after compaction instead of a stale index - #497

Open
ClearVIper3 wants to merge 1 commit into
shareAI-lab:mainfrom
ClearVIper3:fix/s09-memory-index-drift
Open

fix(s09): re-locate the memory turn by identity after compaction instead of a stale index#497
ClearVIper3 wants to merge 1 commit into
shareAI-lab:mainfrom
ClearVIper3:fix/s09-memory-index-drift

Conversation

@ClearVIper3

Copy link
Copy Markdown
Contributor

The memory injection turn was located by a pre-compaction index that
compaction then shifted, so memory was silently dropped whenever
compaction fired. Re-locate the user turn by object identity after each
compaction step instead of trusting the stale index; leave the
compaction functions untouched.

Fixes #496

  `memory_turn` was computed once as `len(messages) - 1` *before* the s08
  compression pipeline runs. `snip_compact` / `compact_history` /
  `reactive_compact` shorten or rebuild the message list, so the index
  drifts: the guard `memory_turn < len(messages)` then fails and the memory
  injection is silently skipped — precisely when compaction triggers (long
  conversations), i.e. when the memory system is supposed to matter most.

  Fix: capture the user-turn *object* and re-locate it by identity after
  each compaction step via the new `_find_memory_turn`, falling back to the
  last str-content user turn if the query was summarized away. No change to
  the s08 compaction functions — the bug was entirely in agent_loop.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

s09_memory:snip_compact 触发后 引发 memory_turn 索引漂移,该轮已检索到的记忆没注入进 prompt

1 participant