Skip to content

The agent that grows with you

docs(memory): say why a claim's weakref callback checks it is still the entry's reference

unsupportedpastels59ee4989a621
diff --git a/agent/memory_caller_scope.py b/agent/memory_caller_scope.py
index 083a32a7e40..a05d2de55d3 100644
--- a/agent/memory_caller_scope.py
+++ b/agent/memory_caller_scope.py
@@ -101,6 +101,8 @@ def caller_scope(bound: Optional[dict[str, Any]], label: str) -> Optional[dict[s
def _forget(pid: int, ref: weakref.ref) -> None:
+ # Only this dead instance's own entry: once it is collected its id() can be reused by a new
+ # provider whose claim already replaced the entry, and that claim must survive.
with _claims_lock:
if _claims.get(pid, (None,))[0] is ref:
del _claims[pid]