Skip to content

Fix/graph recall rebind 281#295

Open
sshekhar563 wants to merge 3 commits into
qbtrix:devfrom
sshekhar563:fix/graph-recall-rebind-281
Open

Fix/graph recall rebind 281#295
sshekhar563 wants to merge 3 commits into
qbtrix:devfrom
sshekhar563:fix/graph-recall-rebind-281

Conversation

@sshekhar563

Copy link
Copy Markdown
Collaborator

Description

This PR resolves Issue #281 where graph-augmented recall silently degraded after a Soul was restored from its state.

The Bug

During initialization (MemoryManager.__init__), the RecallEngine was instantiated with a reference to an empty KnowledgeGraph.
When MemoryManager.from_dict() restored a state, it completely rebuilt the graph and rebounded manager._graph, but the manager._recall_engine continued holding onto the old, empty graph. Because of this stale reference, graph-augmented recall returned empty results for restored souls, even while new observations mutated the new graph correctly.

The Fix

  • Rewired the graph reference inside from_dict() immediately after the KnowledgeGraph is restored: manager._recall_engine._graph = manager._graph.
  • Confirmed that this is the lowest-risk approach for deserialization (other built-in stores like episodic/semantic are updated in-place via .model_validate so they do not suffer from this rebinding hazard).

Testing Added

  • Added a regression test test_from_dict_rewires_recall_engine_graph to tests/test_memory/test_memory.py.
  • The test explicitly mutates a graph, serializes it, and asserts that restored._recall_engine._graph is restored._graph after calling from_dict.

Fixes #281

Resolves qbtrix#281

MemoryManager.from_dict rebuilds the graph but never updated the RecallEngine reference, causing graph-augmented recall to silently degrade by querying an empty graph on restored souls.
Validates that MemoryManager.from_dict properly rewires the recall engine's graph reference after deserialization.
@sshekhar563 sshekhar563 requested a review from prakashUXtech July 7, 2026 14:13
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant