Compare commits

...

1 Commits

Author SHA1 Message Date
Alexander Whitestone
6e8631fdc0 burn: add remove action to on_memory_write bridge
Some checks failed
Forge CI / smoke-and-build (pull_request) Failing after 34s
Extends the memory bridge to fire on_memory_write for the 'remove'
action in addition to 'add' and 'replace'. The holographic provider
now searches for matching facts and lowers trust by 0.4 on remove,
allowing orphaned facts to decay naturally.

Fixes #277
2026-04-10 16:49:48 -04:00
2 changed files with 25 additions and 2 deletions

View File

@@ -248,6 +248,25 @@ class HolographicMemoryProvider(MemoryProvider):
self._store.add_fact(content, category=category)
except Exception as e:
logger.debug("Holographic memory_write mirror failed: %s", e)
elif action == "remove" and self._store and content:
try:
# Search for matching facts and lower trust so they decay naturally
facts = self._store.search_facts(content, limit=5)
for fact in facts:
self._store.update_fact(fact["fact_id"], trust_delta=-0.4)
logger.debug(
"Holographic remove: decayed trust for fact %s: %s",
fact["fact_id"], fact["content"][:60],
)
except Exception as e:
logger.debug("Holographic memory_write remove failed: %s", e)
elif action == "replace" and self._store and content:
try:
# Re-add the new content as a fresh fact
category = "user_pref" if target == "user" else "general"
self._store.add_fact(content, category=category)
except Exception as e:
logger.debug("Holographic memory_write replace failed: %s", e)
def shutdown(self) -> None:
self._store = None

View File

@@ -6086,12 +6086,16 @@ class AIAgent:
store=self._memory_store,
)
# Bridge: notify external memory provider of built-in memory writes
if self._memory_manager and function_args.get("action") in ("add", "replace"):
if self._memory_manager and function_args.get("action") in ("add", "replace", "remove"):
try:
# For remove, use old_text as the searchable content
bridge_content = function_args.get("content", "")
if not bridge_content and function_args.get("action") == "remove":
bridge_content = function_args.get("old_text", "")
self._memory_manager.on_memory_write(
function_args.get("action", ""),
target,
function_args.get("content", ""),
bridge_content,
)
except Exception:
pass