Skip to content
Engineering

Why graphs beat vectors for agent memory

J. Lindqvist · June 19, 2026 · 1 min read

RAG chunks your documents, embeds them, and returns the top-k most similar at query time. It's great for lookup and terrible for reasoning — because similarity throws away structure. Grep has the same problem in a different costume: it finds strings, not relationships.

The multi-hop wall

Ask 'what breaks if I change this function's signature?' and a vector store returns chunks that mention the function, or signatures, or breakage — and hopes the model stitches them together. Grep finds every file containing the name, including comments, tests, and an unrelated variable that happens to shadow it. A graph follows the edges: function → callers → their callers → the schema they serialize. That's a traversal, not a guess.

Structure is extracted, not embedded

Graphify builds those edges from the AST — tree-sitter parsing, done locally, across 36 languages. A call edge exists because the parser found the call, not because two chunks landed near each other in embedding space. Where the model does help — connecting docs, SQL, and Terraform to the code — the resulting edges are tagged INFERRED so you can tell them apart from what was extracted.

A score isn't an answer

The quiet failure of similarity search is that it can't explain itself: a cosine score of 0.83 tells you nothing about why a chunk is relevant. A traversal is its own explanation — the answer is the path, and every node on it is a real file you can open. That's the difference between retrieval that sounds right and retrieval you can check.

Start in one command

Try it on your own repo.

Get started
84,713 stars on GitHub. Read the code.

Evaluating for a team? See Graphify Enterprise →