What Is a Context Graph in AI?
A context graph is a network of memory nodes connected by typed edges — supports, contradicts, supersedes, same_session — that lets an AI system retrieve not just the most similar fact but the web of related context that gives it meaning.
A context graph in AI is a structured network where each node is a memory or fact, and edges represent typed relationships between those memories — such as "this fact supports that fact" or "this memory supersedes an older version." When an AI agent retrieves a fact from the graph, it can traverse the connected edges to surface a chain of related context, not just an isolated data point. This is the difference between retrieving a preference and retrieving the context that explains and validates it.
Why flat retrieval is not enough
Standard vector retrieval returns the k most semantically similar embeddings to a query. This works for isolated facts. It fails when facts derive meaning from their relationships to other facts.
Consider an AI coding assistant. It stores the fact: "User prefers async/await patterns." A cosine search for "how should I handle this database call" retrieves that preference. That's useful. But the full picture includes connected context: why the user developed this preference (a production bug from callback hell in 2024), which projects it applies to (all Node.js projects, not the Python repo), and when it was last updated (three sessions ago, after they refactored the auth module).
Flat retrieval returns the preference. Graph traversal returns the preference and the context that makes the agent competent to use it correctly.
How a context graph is structured
A context graph has three components:
Nodes: Individual memories or facts, stored as embedding vectors with metadata. Each node has an ID, an embedding, importance weight, recall count, and custom attributes (user ID, session ID, timestamp, source).
Edges: Directed, typed, weighted connections between nodes. In Feather DB, nine relationship types are built in:
| Edge type | Semantics | Example |
|---|---|---|
supports | Node A provides evidence for Node B | Performance data supports a design decision |
contradicts | Node A conflicts with Node B | Updated fact vs outdated fact |
supersedes | Node A replaces Node B | New user preference replacing old one |
same_session | Both nodes from the same session | Facts gathered in one conversation |
caused_by | Node A was triggered by Node B | A bug caused by a config change |
derived_from | Node A is a conclusion from Node B | A recommendation derived from analysis |
related_to | Thematic connection | Two features that interact |
parent | Node B is a sub-concept of Node A | A project and its sub-tasks |
child | Node A is a sub-concept of Node B | A sub-task under a project |
Traversal: BFS (breadth-first search) from a seed node, following edges up to a configurable hop depth. The context_chain API in Feather DB combines vector search (to find seed nodes) with graph traversal (to surface connected context) in a single call.
Context graphs vs knowledge graphs
Knowledge graphs (like those used in Google's Knowledge Graph or enterprise ontologies) are typically static, manually curated, and designed for structured data about entities and their properties. A context graph for AI agent memory is dynamic, auto-populated from agent interactions, and designed for unstructured experiential context.
| Property | Knowledge graph | Context graph (AI memory) |
|---|---|---|
| Population | Manual or ETL pipelines | Automatic from agent interactions |
| Content type | Structured entities and relations | Unstructured memories and facts |
| Retrieval | SPARQL / graph query language | Vector search + BFS traversal |
| Lifecycle management | Manual schema evolution | Automatic via decay scoring |
| Scale target | Millions of entities | Thousands to hundreds of thousands of memories |
How context graphs improve agent responses
The improvement is in context depth. Without a graph, an agent retrieves isolated facts. With a graph, an agent retrieves facts plus the web of supporting evidence, contradicting information, and temporal context that makes those facts interpretable.
Practical example in performance marketing: Feather DB's context graph for Hawky.ai connects ad creative nodes to performance metric nodes to audience segment nodes to brand guideline nodes. When the system needs to generate a new creative for a specific audience segment, it retrieves not just the best-performing creative for that segment, but the performance data that made it work, the brand guidelines it followed, and any superseded variants that failed — all in one traversal.
The result is informed generation rather than context-free generation. The creative AI knows what worked and why, producing variants that start from proven context rather than from blank slate.
Building a context graph with Feather DB
import feather_db as fdb
db = fdb.DB.open("agent_memory.feather", dim=768)
# Store two related memories
db.add(id="pref_v2", vec=embed("User prefers async/await"), meta=fdb.Metadata(importance=0.9))
db.add(id="pref_v1", vec=embed("User prefers callbacks"), meta=fdb.Metadata(importance=0.2))
# Link: v2 supersedes v1
db.link(from_id="pref_v2", to_id="pref_v1",
rel_type="supersedes", weight=1.0)
# Link: performance data supports the preference
db.link(from_id="perf_data_001", to_id="pref_v2",
rel_type="supports", weight=0.8)
# Retrieve with graph traversal — 2 hops
chain = db.context_chain(
query_vec=embed("how should I handle async database calls?"),
k=5,
hops=2
)
# Returns: pref_v2 (direct match) + pref_v1 (superseded) + perf_data_001 (supporting evidence)
FAQ
What is a context graph used for in AI agents?
Context graphs are used to store and traverse the relationships between an agent's memories — so that retrieving one fact can surface its supporting evidence, contradicting information, and temporal history. This produces richer, more accurate agent responses than flat vector retrieval.
How is a context graph different from a knowledge graph?
Knowledge graphs store structured entity relationships (manually curated, schema-driven). Context graphs store unstructured agent memories connected by experiential relationships (auto-populated, schema-flexible). Context graphs are designed for dynamic, evolving agent memory rather than static knowledge representation.
Does Feather DB support custom relationship types?
Feather DB ships with nine built-in relationship types. Custom relationship type strings can be stored in edge metadata for use cases that require domain-specific relationship semantics beyond the built-in set.
How deep should graph traversal go?
For most agent memory use cases, 2–3 hops is sufficient. At 2 hops, a retrieved preference surfaces its supporting evidence and superseded predecessor. Beyond 3 hops, the traversal tends to surface loosely related context that adds noise rather than signal. Configure hops conservatively and increase if the retrieved chains are too shallow.
Does graph traversal affect retrieval latency?
BFS traversal on a context graph adds latency proportional to the number of edges traversed. For typical agent memory graphs (hundreds to low thousands of nodes), this adds sub-millisecond overhead on top of the 0.19ms base ANN search latency. At very large scales, limit hop depth to control traversal cost.