[BUG] Memory consolidation 'update' action silently flips private memories to public and drops their source
Summary
In EncodingFlow.execute_plans() (lib/crewai/src/crewai/memory/encoding_flow.py:477-487), when the consolidation LLM returns an update action for an existing record, the replacement MemoryRecord is rebuilt field-by-field from existing but omits source and private. MemoryRecord defaults them to None/False, so any remember() that is deemed similar (>= 0.85) and updated by the LLM silently:
- flips a private memory to
private=False, and - loses its provenance
source.
Consequence: the record becomes visible to every recall caller - both unified_memory.py:751-761 (shallow) and recall_flow.py:109-118 (deep) only filter with not r.private or (source is not None and r.source == source). By contrast, Memory.update() (unified_memory.py:907) preserves unspecified fields via model_copy.
Steps to Reproduce
Real EncodingFlow with fake storage/LLM/embedder:
- Existing record:
{id: 'rec-1', scope: '/notes', source: 'user-42', private: True}. - Consolidation LLM returns
ConsolidationPlan(actions=[ConsolidationAction(action='update', record_id='rec-1', new_content='merged v2')], insert_new=False). flow.kickoff(inputs={'items': [{'content': 'user-42 secret v2', 'scope': '/notes', 'categories': ['x'], 'importance': 0.9}]}).- Inspect the record passed to
storage.update().
Observed: private=False, source=None (scope/categories/metadata/importance are preserved). Expected: private=True, source='user-42'.
Possible fix
Add source=existing.source, private=existing.private, to the MemoryRecord(...) construction in execute_plans().
Side note: the encode-side consolidation search (encoding_flow.py:167-185, _search_one) currently feeds private records' content to the consolidation LLM with no source check - the recall paths filter, the encode path does not - which may deserve a separate look.
Disclosure
This issue and the upcoming PR are AI-agent-assisted (generated with an AI coding agent). Please apply the llm-generated label per CONTRIBUTING - I cannot set labels without triage permission.
This is a classic problem with in-place updates: when consolidation rebuilds a record, any field not explicitly carried over gets silently reset to defaults.
We solved this in MemTether by eliminating in-place updates entirely: corrections use bi-temporal supersession — the old record is marked superseded (with valid_to and invalidated_at timestamps) and a new record is created. Nothing is ever overwritten in place.
This means:
- The
privateflag from the original record is always preserved (it's on the old record, which still exists) - You can audit the full chain: who wrote what, when it was "updated", what changed
- If the consolidation LLM makes a mistake, you can revert by querying the superseded record
The trade-off is that you need a query layer that respects the temporal model (as_of queries), but that's much safer than losing metadata silently.
This issue is stale because it has been open for 30 days with no activity. Remove stale label or comment or this will be closed in 5 days.