Context Graphs: Agent Memory with Neo4j
Give AI agents persistent memory with Neo4j context graphs. Build short-term, long-term, and reasoning memory, then query the agent's full trace.
In this 3-hour course, you will learn
Context Graphs: Agent Memory with Neo4j teaches you how to give AI agents persistent, explainable memory using Neo4j and the neo4j-agent-memory Python library. You will build an agent that remembers conversations, accumulates knowledge about the entities it encounters, and records every step of its reasoning as a queryable context graph.
Most AI agents are stateless. Each session starts from nothing, knowledge learned in one conversation never carries into the next, and when an agent makes a decision there is no record of why. This course shows you how a graph-backed memory layer closes those gaps, and why a Full definition for knowledge graph (opens in a new tab)A representation of real-world entities and their relationships, stored according to organizing principles, typically in a graph database. is a better foundation for agent memory than vector Full definition for embedding (opens in a new tab)Information represented as a numerical vector, positioned so that similar information sits close together. alone.
Context Graphs
Build a Neo4j-backed context graph that persists an AI agent's knowledge across sessions, linking entities, relationships, and conversation history in a queryable structure.
Agent Memory
Implement short-term, long-term, and semantic memory layers so an agent recalls prior interactions, user preferences, and factual knowledge without re-prompting.
neo4j-agent-memory
Configure and extend the neo4j-agent-memory Python package to store, retrieve, and update agent memory records directly in a live Neo4j database.
Reasoning Traces
Query an agent's full reasoning trace from the graph to inspect which memories were retrieved, how decisions were made, and where errors or gaps occurred.
POLE+O
Apply the POLE+O model — Person, Object, Location, Event, and Organisation — to extract and store structured entities from raw agent conversation turns.
4 modules, 2 hours 30 minutes.
Who this course is for
This course is for developers and AI engineers who have built or experimented with LLM-powered agents and hit the limits of stateless sessions. If your agent forgets users between conversations, cannot explain its decisions, or cannot share what it learns across sessions, this course addresses exactly those problems. It also suits architects evaluating agent memory approaches: the course compares graph-based memory with vector stores directly, so you finish with a clear picture of when Full definition for relationship (opens in a new tab)A named, directed connection between two nodes. Every relationship has a type, a start node and an end node. and Full definition for traversal (opens in a new tab)Following relationships from one node to the next to reach other parts of a graph. beat similarity search for recall, and how reasoning traces support audit and compliance requirements. You should have completed Neo4j Fundamentals, Cypher Fundamentals, and Neo4j & GenerativeAI Fundamentals, and be comfortable reading and writing Python, since you will query the memory graph directly to inspect what your agent knows.
What you'll build and do
You work in a blank Neo4j sandbox and build the memory graph up from nothing, so you see exactly what each API call writes to the database. The course provides a configured environment with the
neo4j-agent-memorylibrary, an Go to glossary for large language model (opens in a new tab)A model trained on text to predict the next token, and so to generate language. proxy, and starter code for each challenge.You will store your first memory and inspect the Full definition for node (opens in a new tab)A vertex in a graph. In a property graph it can carry labels and properties. it creates, build a conversation memory layer that gives an agent recall across sessions, and run an entity extraction pipeline that promotes people, places, and objects from raw messages into structured long-term memory. In the final module you will build and run a complete Pydantic AI agent that records its full reasoning trace into Neo4j, then write Full definition for Cypher (opens in a new tab)Neo4j's implementation of GQL, the ISO standard query language for graph databases. It is declarative: you describe the pattern to find, and the database decides how to find it. queries against that trace to answer the question every stakeholder eventually asks: what did the agent do, and why? Each challenge includes automated checks that verify your graph contains the expected data.
Where to go next
The knowledge graphs your agent builds in this course are constructed by an Go to glossary for large language model (opens in a new tab)A model trained on text to predict the next token, and so to generate language. extraction pipeline. Constructing Knowledge Graphs with Neo4j GraphRAG for Python goes deeper into that process, teaching you how to control schemas, chunking, and entity resolution. If you want to expose your memory graph to agents through tools, Developing with Neo4j MCP Tools shows you how agents can query Neo4j through the Model Context Protocol. This course also counts toward the Neo4j & Generative AI Certification, which covers Full definition for GraphRAG (opens in a new tab)Retrieval-augmented generation whose context comes from a knowledge graph, so the model can follow the relationships between facts., Full definition for vector search (opens in a new tab)Finding the records whose vectors lie closest to a query vector., and agentic Full definition for pattern (opens in a new tab)A graph structure written in Cypher, such as a node joined to another node by a relationship. with Neo4j.
Workshop AI access
This workshop provides temporary access to a hosted language model. Accept the terms and copy your credentials from within any lesson.
Default model: gpt-4o-mini