Skip to content

xmemory: opt-in mirroring of memorization-sweep transcripts (text-only) - #270

Merged
pufit merged 1 commit into
mainfrom
pufit/xmemory-conversation-sweep
Aug 5, 2026
Merged

xmemory: opt-in mirroring of memorization-sweep transcripts (text-only)#270
pufit merged 1 commit into
mainfrom
pufit/xmemory-conversation-sweep

Conversation

@pufit

@pufit pufit commented Aug 5, 2026

Copy link
Copy Markdown
Member

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:

xmemory:
  index_conversations: true   # default: false

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 via write_async with FAST extraction — transcripts are high-volume; the configured extraction_logic still governs memorize-tool writes.
  • AgentEngine.schedule_xmemory_transcript() — fire-and-forget background task (reuses the _memorize_bg_tasks lifecycle) 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.
  • Best-effort by design: the sweep watermark belongs to memU — a window whose xmemory write fails is logged and not retried. A failed chunk abandons the remaining chunks instead of hammering a down service.
  • XmemoryConfig.index_conversations — off by default; full transcripts leave the machine only when the operator explicitly enables it. The xmemory section already requires restart on config reload, so no config_reload changes needed.

Not changed

  • memU sweep behavior, watermarks, and the memorize/memory_recall handlers (only a stale comment updated).
  • The CLI conversation-backfill path stays memU-only (recovery tool, constructs its own bridge).

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.

Generated by Nerve

@pufit
pufit merged commit eeacc61 into main Aug 5, 2026
2 checks passed
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.

1 participant