You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
feat: add overwrite guard to write_note tool (#625)
write_note now errors by default when a note already exists, preventing
silent data loss from autonomous agents that accidentally overwrite
accumulated content. The error message suggests edit_note alternatives.
- Add `overwrite` parameter (bool | None) to write_note — explicit True
to replace, False/None consults config default
- Add `write_note_overwrite_default` config field (default: False) so
users can globally restore pre-v0.20 upsert behavior
- Guard lives entirely at the MCP tool layer — no API/service changes
- JSON output returns structured `NOTE_ALREADY_EXISTS` error on conflict
- Update tool annotations: destructiveHint=True, idempotentHint=False
- Fix existing tests that relied on implicit update behavior
- Add 7 new tests (6 unit + 1 integration) for the overwrite guard
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Signed-off-by: phernandez <paul@basicmachines.co>
Copy file name to clipboardExpand all lines: src/basic_memory/config.py
+10Lines changed: 10 additions & 0 deletions
Original file line number
Diff line number
Diff line change
@@ -245,6 +245,16 @@ class BasicMemoryConfig(BaseSettings):
245
245
description="Disable automatic permalink generation in frontmatter. When enabled, new notes won't have permalinks added and sync won't update permalinks. Existing permalinks will still work for reading.",
246
246
)
247
247
248
+
write_note_overwrite_default: bool=Field(
249
+
default=False,
250
+
description=(
251
+
"Default value for write_note's overwrite parameter. "
252
+
"When False (default), write_note errors if note already exists. "
253
+
"Set to True to restore pre-v0.20 upsert behavior. "
254
+
"Env: BASIC_MEMORY_WRITE_NOTE_OVERWRITE_DEFAULT"
255
+
),
256
+
)
257
+
248
258
ensure_frontmatter_on_sync: bool=Field(
249
259
default=True,
250
260
description="Ensure markdown files have frontmatter during sync by adding derived title/type/permalink when missing. When combined with disable_permalinks=True, this setting takes precedence for missing-frontmatter files and still writes permalinks.",
0 commit comments