Skip to main content

Graph Memory

Standard entity memory stores flat records — a list of names, types, and attributes. Graph memory upgrades this to a full knowledge graph where entities are connected by typed, directed relationships with temporal metadata. This lets agents answer questions like “Who on the frontend team works with Raj?” or “What projects depended on the billing API before it was deprecated?” — queries that require traversing relationships, not just keyword search.

Quick Start

With graph enabled, the agent automatically:
  • Extracts entities and relationships from conversations
  • Exposes graph tools (query_graph, traverse_entity, add_relationship) to the agent
  • Injects relevant subgraph context into the system prompt before each run

Neo4j Backend

For production, use Neo4j as the graph store:
Neo4j gives you native graph traversal performance and Cypher queries under the hood, which matters when the graph grows past a few thousand nodes.

Auto-Extraction from Conversations

When graph memory is enabled, the background extraction step (after each run) identifies entities and their relationships from the conversation:
The extraction model determines relationship types automatically. Over time, repeated mentions reinforce existing edges and add new ones.
The agent can query the graph through auto-exposed tools or you can query it programmatically:

Agent Tools (Automatic)

When graph memory is enabled, three tools are automatically added:

Programmatic Access


Temporal Awareness

Every node and edge in the graph carries temporal metadata:
When the extraction model detects a contradiction (e.g., “Raj moved from frontend to platform team”), the old MEMBER_OF → Frontend Team edge is marked with invalidatedAt and a new MEMBER_OF → Platform Team edge is created. The old data is never deleted — see Temporal Awareness for details. By default, buildContext() only injects currently-valid nodes and edges. To include historical data:

Configuration


Graph Store Implementations

Both implement the GraphStore interface:

Cross-References