agentmemory icon indicating copy to clipboard operation
agentmemory copied to clipboard

Claude bridge sync overwrites a hand-written MEMORY.md

Open Rex57 opened this issue 1 month ago • 1 comments

Current-main boundary

On main 007a1a7 (0.9.30), mem::claude-bridge-sync (also the default direction of the memory_claude_bridge_sync MCP tool) serializes the strongest current memories into Markdown and writes it to the configured MEMORY.md with writeFileSync. It does not check what the file holds. A MEMORY.md that the user or Claude Code curated by hand is replaced in full, with no backup.

Reproduction and results (from the code path)

  1. Keep a hand-written MEMORY.md (for example a Claude Code project memory index).
  2. Set CLAUDE_MEMORY_BRIDGE=true with that file as the bridge path, restart.
  3. Call memory_claude_bridge_sync (or POST the bridge sync route).
  4. Result: the file now starts with # Agent Memory (auto-synced by agentmemory); the previous content is gone. The written list comes from all memories in the store, cut at the line budget.

Required behavior

  • Sync only overwrites a file that agentmemory wrote (it starts with the auto-sync header) or a file that does not exist.
  • For any other existing file, sync writes nothing and returns success: false with an error that names the file and says why.
  • Read direction is unchanged.

Acceptance checks

Tests: missing file → written; file with the auto-sync header → rewritten; hand-written file → unchanged on disk and an error result.

Source and existing work

mem::claude-bridge-sync.

#1103 is about the bridge path ignoring CLAUDE_CONFIG_DIR, not about overwriting.

Environment: agentmemory 0.9.30, Node v26.10.0, macOS 27.0.1 (arm64).

Rex57 avatar Oct 08 '26 06:10 Rex57

Fixed on main by #1525: mem::claude-bridge-sync now refuses to replace an existing MEMORY.md (any existing file, not only hand-written ones) and filters memories by project. Closing; #1505 is closed as superseded.

Rex57 avatar Nov 01 '26 05:11 Rex57