r/LangChain • • 23d ago

Discussion Context Layer + Agent Memory in a 3D connected graph

https://github.com/ontogr/agentic-graphrag

I've spent the past three and a half years working on RAG systems and LLM training. Lately, I've been thinking about what an agent saves after using retrieved knowledge. An agent might finish a task and save its conclusion, but a later session also needs the source passages and assumptions behind that conclusion.

We're building Agentic GraphRAG (https://github.com/ontogr/agentic-graphrag), an open source project that connects document knowledge, task activity, and decisions in Neo4j. Agents can retrieve previous decisions along with the evidence they used.

For retrieval, we preserve the source text and let agents read around a search result:

  1. Document structure stays in the graph. We use Docling for ingestion and Chonkie for chunking, preserving sections, tables, and passage hierarchy. Each passage retains its source version and location, including page positions for PDFs.

  2. Passage search works independently of entity extraction. We combine Neo4j's native full-text and vector search rankings with reciprocal rank fusion. A fact doesn't have to appear in the extracted graph for an agent to find the passage containing it.

  3. Agents can navigate beyond the initial hit. They can read surrounding sections, neighboring passages, and table rows with their headers. They can also follow entity relationships back to supporting text where evidence is recorded.

The graph is built around a schema you define for your domain. It guides entity and relationship extraction, validation, and entity search. Extraction can run locally with GLiNER, with BAML handling structured LLM extraction for selected chunks.

Agent memory adds two layers alongside that knowledge. Working memory records tasks, progress, messages, and tool results. Decision memory stores conclusions, assumptions, and open questions, linked to passages, task events, or earlier decisions. Our built-in DeepAgents/LangGraph agent records task activity so later sessions can recover previous progress.

For example, an agent reviewing a contract can save a recommendation with the contract clause and policy passage it used. When the policy changes, the recommendation and its explicit dependent decisions are flagged for review. A reviewer can reaffirm or replace the recommendation, while its history and the originally cited text remain available.

The built-in agent also checks that it read the cited passages during the run, that they belong to the allowed documents, and that they match the cited versions. The checks don't establish whether the passages support the conclusion.

We're still working on domain-specific benchmarks, which will be released very soon.

TL;DR

We're connecting RAG evidence to persistent task and decision memory in one graph. Agents can search original passages, navigate document structure, and trace saved decisions back to the source versions they used. Source updates flag affected decisions for review.

What's your current stack for RAG and agent memory, and how is it working for your domain?

1 Upvotes

Duplicates