Course map · Module 3 of 6

State, Memory and Knowledge Graphs

Central question: What should exist after the current run ends?

The persistence module. Checkpoints that survive crashes, the three memory tiers, the five-phase loop that turns documents into a growing knowledge graph, and retrieval that traverses instead of guesses — down to the router-and-index layer that makes even a folder of markdown behave like a graph.

Tool labs · LlamaIndex, Neo4j, LangGraph persistence, OpenAI Agents SDK sessions   Expert lenses · Jerry Liu, Emil Eifrem
LESSON 3.1

Working state, checkpoints, and the run that survives

Core idea

State inside a run must survive the run's failures. Checkpointing after each node buys three superpowers: resume from the last good node instead of restarting, replay a run to see exactly where it went bad, and pause indefinitely for human input. One caution: nodes after a checkpoint re-execute on replay, so any node with side effects must be idempotent — safe to run twice.

Expert lens

Harrison Chase's LangGraph bet its identity on this: durable execution, streaming, persistence, human-in-the-loop — orchestration you can stop and resume.

Tool lens

LangGraph checkpointers persist full graph state per step to any backing store; OpenAI Agents SDK sessions carry conversation state across runs; both make 'resume' a one-liner.

Build

Add a checkpointer to your Module 2 research graph. Kill the process mid-run. Resume it.

Verify

The resumed run must complete without re-calling the already-finished researcher nodes (check the trace), and the double-executed node after the checkpoint must produce no duplicate side effects.

Connect

Adds checkpoint/resume; Module 6 extends it to production recovery.

LESSON 3.2

Session memory versus durable memory

Core idea

Three memory tiers, three lifetimes: the context window (this exchange), session memory (this conversation), durable memory (this relationship). Bigger windows didn't solve memory — they postponed forgetting to the next session. The engineering question of the decade: what deserves to survive the run, and in what structure?

Expert lens

The Zep paper's framing became canonical: RAG was built for static documents; agents need memory that updates from live conversations and business data simultaneously.

Tool lens

OpenAI Agents SDK sessions handle the middle tier; LangGraph stores + Neo4j handle the durable tier. The routing rule from the field: relational/multi-hop questions → graph; broad semantic search → vectors; this-session facts → context.

Build

Take one long working conversation and triage every fact in it into the three tiers, with one sentence on why.

Verify

A fresh session given only your durable-tier extraction must correctly answer three questions about the work. If it can't, your triage missed the load-bearing facts.

Connect

Adds memory-tiers; the persistent loop of 3.3 fills the durable tier.

LESSON 3.3

The persistent knowledge loop: Extract → Resolve → Assemble → Verify → Persist

Core idea

Durable memory is built by a pipeline, not a dump. Extract entities and typed claims from raw material (cheap model, schema-forced). Resolve aliases into canonical nodes ('Buzz Aldrin' = 'Edwin Aldrin' — judgment, so a stronger model). Assemble typed edges with provenance and confidence on every claim. Verify before writing — contradictions get flagged or superseded, never silently overwritten. Persist, then repeat: the graph grows, it is never rebuilt.

Expert lens

Emil Eifrem on relationships as first-class data; the bi-temporal insight from Zep/Graphiti: every edge carries when-it-happened and when-we-learned-it, so 'what did we believe in June' stays answerable.

Tool lens

Neo4j stores the graph and Cypher queries it; LlamaIndex extraction pipelines feed it; Graphiti automates the temporal bookkeeping if you want the managed version.

Build

Run the five-phase loop on twenty documents of your own. Extraction on a cheap model, resolution on a strong one — record the cost of each phase.

Verify

Query the graph for one fact that appears under different names in different documents. One canonical node must answer, with provenance listing both sources.

Connect

Adds the extract-resolve-assemble-verify-persist loop — Capstone B is this lesson at full scale.

LESSON 3.4

GraphRAG and memory consolidation

Core idea

Retrieval that traverses beats retrieval that guesses — on multi-hop questions, production reports put graph traversal 36–46% ahead of vector-only search. GraphRAG combines both: vectors find entry points, edges walk to the answer, and every claim cites a specific edge. Consolidation keeps it healthy: periodic passes that merge duplicates, decay stale confidence, and supersede contradictions — memory hygiene as a scheduled graph job.

Expert lens

Jerry Liu's agentic-retrieval framing: agents should route between retrieval strategies per question, not commit to one; the router itself is judgment.

Tool lens

Neo4j's GraphRAG stack combines vector search with Cypher traversal; LlamaIndex router agents pick the strategy per query.

Build

Build a two-strategy retriever over your 3.3 graph: vector entry + graph walk. Add a router that picks per question.

Verify

Ask one multi-hop question ('which sources contradict X?'). The graph path must answer it correctly and cite edges; the vector-only path must demonstrably fail or hallucinate — document both.

Connect

Completes the memory cluster; your learning graph itself now demonstrates the pattern it stores.

LESSON 3.5

The two graphs of a working swarm: commit DAG × knowledge graph

Core idea

A multi-agent system needs two graphs, and they must not be collapsed into one. The commit DAG stores work lineage: what changed, which experiment is the parent, which lineages are still alive. The knowledge graph stores domain meaning: which entities exist, which sources support which relation, which claims conflict. Production systems link them — agent_run —produced→ claim —about→ entity, claim —supersedes→ claim, run —modified→ commit —evaluated_by→ evaluation — so every fact knows the work that produced it.

Expert lens

The Karpathy→Anthropic synthesis (J. Parajan, July 2026): swarms scale not by copying every worker transcript into an orchestrator’s window, but by writing findings into shared graph state. The agent forgets; the graph does not. Failed experiments stay addressable as evidence, and a new worker queries the lineages it needs instead of replaying history.

Tool lens

Anthropic’s Knowledge Graph Cookbook versus Neo4j. The cookbook replaces a trained NLP pipeline with structured outputs: a small model extracts typed entities and relations against a Pydantic schema (“the schema is the only training data”), a stronger model resolves aliases as a reasoning task — merges reversible, aliases and rationale retained — and assembly attaches provenance to every edge. The payoff is graph-grounded evaluation: a critic checks each claim against edges and returns structured missing-evidence feedback (“no supported path from Vendor X to Incident Y; required: a source-backed supplied edge”) — far more actionable than a free-form review.

Build

Build context from the graph, not by dumping it: resolve the task’s entities, expand one–two hops over allowed edge types, prioritize recent verified claims, include known conflicts, serialize within a token budget, and attach stable edge IDs so answers can cite them.

Verify

Hold your system to the traceability invariant: every important output can be traced to an objective, a plan, an artifact, a source, a graph path, an evaluator decision, and a bounded execution record. When that statement is false, adding more agents increases opacity, not capability.

Connect

Adds commit-DAG ≠ knowledge-graph to the memory cluster. Module 6 turns the traceability invariant into a production checklist.

LESSON 3.6

The router and the index — a knowledge graph in plain files

Core idea

A folder of markdown becomes a graph the moment you add the two files most vaults never get: a router (read every session, kept under 500 tokens — a map, not a manual) and an index (one line per note: name, link, one sentence). Nodes hold one idea per file — the mega-note that covers ten topics costs all ten to use one line. Edges are purposeful pointers, not the pretty graph view: “ten sharp edges make a graph; fifty is noise wearing a graph’s clothes.” The distinction that organizes everything: a pile (ask anything, read everything), a graph (ask anything, read two or three files), a system (a graph with memory that compounds — a state file every run reads first and writes last).

Expert lens

unicode (@unicodef1wn)’s 458K-view 11-step Obsidian-to-graph roadmap, and its sharpest line: “The pretty graph is for you. The index is for the model. Only one of them makes it faster.” The hoarder owns everything and finds nothing; the librarian hands you the right book in five seconds.

Tool lens

Retrieval here is logic, not model calls: strip the question to keywords → score nodes from the index alone (opening nothing) → open only the best match → read only the answering section → follow one edge if it points elsewhere → the model runs once, evidence in hand. Five of six steps cost zero tokens — the same traversal-over-guessing shape as this module’s GraphRAG lab, at markdown scale.

Build

Impose the layout on a real notes folder: ROUTER.md (≤500 tokens), index.md (one line per node, generated), split one mega-note by idea, add state.md that the session ends by writing.

Verify

Prove it — the step everyone skips: run the same ten questions against the raw folder and the graph. Compare tokens, wall-clock, and correctness in an actual table. Drift check: every node has exactly one index line.

Connect

Adds router-index-nodes-edges and retrieval-as-logic. The state file is Lesson 3.2’s session memory, in a file you own — swap the model next year and lose nothing. Source: @unicodef1wn.

Unlock the rest of Module 3

Lesson 1 of every module is open. The full module — all lessons, the tool lab, and the graded project — unlocks with any plan.

Try Free — 30 Days (no card) Own the course — $6.93 Compare plans

Purchased already? Sign in with your checkout email.

Tool lab

Neo4j + LlamaIndex + LangGraph persistence

One connected lab: LangGraph checkpoints keep the run alive, LlamaIndex pipelines extract entities and claims, Neo4j stores the canonical graph with provenance, and a router agent traverses it. Runs locally in Docker — one container, durable memory across every restart.

Module project · graded by evidence

Document collection → source-grounded knowledge graph

Turn an unstructured document collection (yours, or the provided 40-document set) into a knowledge graph an agent can traverse and cite.

Acceptance criteria — all must be demonstrably true:

  • Every edge carries provenance (source doc) and confidence
  • At least one alias pair resolved into a canonical node
  • At least one contradiction represented as supersession, not overwrite
  • A multi-hop question answered by traversal, with edge citations, that vector-only retrieval gets wrong