xmemory: opt-in mirroring of memorization-sweep transcripts (text-only) - #270
Merged
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What
Lets xmemory receive all of a session's text — the same message windows the memU memorization sweep already indexes — behind a new opt-in flag:
Until now xmemory only ever saw individual
memorize-tool facts; the sweep was memU-only by design. With the flag set, every window the sweep indexes into memU (periodic sweep, session close, scheduled memorize, session delete) is also mirrored to xmemory as a transcript.How
XmemoryBridge.memorize_conversation(session_id, messages)— flattens messages to text-only lines ([ts] role: content), mirroring the memU sweep's payload contract exactly: role + content only — thinking and tool blocks/results are never sent. Transcripts are split at message boundaries into ~64 KB chunks (oversized single messages are hard-split) and each chunk is enqueued viawrite_asyncwith FAST extraction — transcripts are high-volume; the configuredextraction_logicstill governsmemorize-tool writes.AgentEngine.schedule_xmemory_transcript()— fire-and-forget background task (reuses the_memorize_bg_taskslifecycle) called from_memorize_session,_memorize_incremental, and the session-delete route right where memU gets the same window. A slow/failing xmemory never extends the global memorize lock or affects the memU pass.XmemoryConfig.index_conversations— off by default; full transcripts leave the machine only when the operator explicitly enables it. Thexmemorysection already requires restart on config reload, so noconfig_reloadchanges needed.Not changed
memorize/memory_recallhandlers (only a stale comment updated).Tests
17 new tests in
tests/test_xmemory_bridge.py: transcript flattening excludes thinking/blocks/empty messages; chunk headers, boundaries, and oversized-message hard-split; opt-in gating (config default, unavailable bridge, engine scheduler); FAST extraction override; stop-on-first-failure; engine sweep mirroring the exact memU window; task-failure isolation. Full suite: 3014 passed.