Repository navigation
context-graph: embed messages, entities and edges inside Memgraph for recall - #422
Merged
Merged
Conversation
… recall Implements the #393 decisions. sessions-graph's new embeddings module embeds a session's messages (Action.text), the entities mentioned in its chunks, and its extracted edges (r.text) through MAGE's embeddings.text, default BAAI/bge-small-en-v1.5. Each vector records embedding_model; one from another model counts as missing and is replaced, so models never mix. - SESSION_END always spawns a detached `sessions-graph embed --session`, independent of auto_reconcile; it gets the Memgraph config, not the LLM keys. Reconciliation embeds what it wrote; a failure there never fails the reconciliation. - The Session records embedding_status (completed with the model, or failed with the error); `sessions-graph embed --pending` retries. - agent-context-graph: `recall.embedding_model` config key, kept across bootstrap rewrites; doctor checks embeddings when sessions-graph is enabled; bootstrap and the setup docs suggest memgraph-mage. Closes #416.
This was referenced Oct 5, 2026
antejavor
added a commit
that referenced
this pull request
Oct 5, 2026
Resolve the claude_code/codex adapter conflicts with #427 by keeping this branch's declarative adapters and carrying #427's reply rules into the shared turn_end rule: a blank reply records nothing, and the reply's text is not duplicated into its metadata. #427's tests now expect a turn end, not a session end, after the reply. main's sessions-graph spawns the no-LLM `embed` step on SessionEnd (#422), which Codex recall (#426, #427) relied on via the per-turn Stop. Since a Stop is now a TurnEnd, sessions-graph spawns `embed` on TurnEnd too, so every runtime's turns are embedded as they end, including runtimes with no session-end hook. LLM reconciliation stays on SessionEnd only.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Closes #416. Implements the decisions in #393; part of map #390 (#415 → #416 → #417 → #418).
What
sessions-graphembeddings.py:embed_sessionembeds three units through MAGE'sembeddings.text, 64 texts per call:Action.text, written by actions-graph since context-graph: message actions carry their plain text #421);r.text), reached through those entities because edge properties carry no index.BAAI/bge-small-en-v1.5by default, which is what the benchmark measured. Each vector recordsembedding_model. A vector from another model counts as missing and is replaced, so vectors from two models never mix.EmbeddingUnavailableErrorcovers a missing module (plain Memgraph) or a model that can't load.SessionsGraph:embed_session()recordsembedding_status:completedwithembedding_model, orfailedwithembedding_error.get_pending_embedding_sessions()returns sessions whose embedding failed, never ran, or used another model.sessions-graph embed (--session ID | --pending) [--limit N] [--model M]. The model comes from the flag, thenrecall.embedding_modelin the config, then the default.SESSION_ENDalways spawns a detachedembed --session, independent ofauto_reconcile. It costs no LLM, and the hook never waits on the model._child_env(llm=False)).agent-context-graphrecall.embedding_modelkey, preserved across bootstrap rewrites likeauto_reconcile.doctor --connector sessions-graph: adds anembeddingscheck that loads the model inside Memgraph and reports its dimension, or explains that MAGE (2 GiB or more) is needed.memgraph/memgraph-mage.Tests
Suites:
sessions-graphagent-context-graphNew end-to-end tests on real MAGE:
The chunk, entity and edge are hand-made in extraction's shape. Reconciliation's own embed call runs only in the existing OpenAI-gated end-to-end test.
Checked by hand:
memgraph/memgraph:3.10.0, embedding raises "There is no procedure named 'embeddings.text'" and the session recordsfailed.doctor's check reportsBAAI/bge-small-en-v1.5 (384 dimensions)on MAGE, and fails clearly for a model that can't load.