Adding Episodic Memory to AI Agents: An Analysis of CtxVault's Open-Source Memory Layer

CtxVault adds bitemporal episodic memory to agents, making fact changes traceable and auditable.
CtxVault is an MIT-licensed, locally-running agent memory layer that adds episodic memory alongside semantic and skill memory. Each fact carries two dates—its real-world validity period and when the memory learned it—and five primitives (supersede, revise, invalidate, confirm, dispute) preserve fact change history, flagging conflicts without forcing a resolution. Its core capability is valid_at and known_at bitemporal queries distinguishing "what was true then" from "what was known then." It integrates with LangGraph via the MCP standard protocol, with server-side vault-level access control via the --agent parameter. It currently lacks graph memory, automatic file system sync, and automatic fact extraction from conversations, and the author is still weighing whether to add an extraction layer.
Why Agents Need "Episodic Memory"
Long-running AI agents face an awkward reality: they can't remember what they once believed. When a fact changes, the agent simply overwrites the old value in memory, and a month later no one can say what it was thinking at the time or why it acted that way. Vector stores have no concept of "this was true until April"—and that's exactly the problem Reddit user Filippo Venturini is trying to solve with his open-source project CtxVault.
CtxVault is an MIT-licensed, locally-running agent memory layer. The author previously released a version containing only semantic memory and procedural memory, and has now added a third type: episodic memory. Its core goal isn't to store more—it's to store "time."

Episodic memory is a concept from cognitive science referring to memory of events occurring at specific times, places, and situations, as opposed to semantic memory, which stores general knowledge. In the AI agent context, episodic memory specifically means a temporal memory structure that records "when a fact was true and when the system learned it." The key difference from traditional vector databases is this: vector stores typically keep only the latest state, and once an old value is overwritten it can't be traced back; episodic memory attaches a validity time interval and a recording timestamp to each fact, supporting queries and audits of historical states—making the agent's decision process explainable and reviewable.
Three Kinds of Memory, One Folder Structure
CtxVault organizes all memory into a set of folders called "vaults," each belonging to one of three types:
- Semantic memory: documents, local embeddings, retrieval by meaning.
- Skill memory: process descriptions written in Markdown, which agents read by name.
- Episodic memory: facts with two dates—the time period during which they were true in the real world, and the time the memory learned them.
The third type is what the author cares about most. It makes "true at the time" and "known at the time" two separately queryable dimensions, rather than a single current state that gets repeatedly overwritten.
The Five Primitives of Episodic Memory
CtxVault designs several operation primitives for episodic memory, covering common patterns of fact change:
- supersede: the fact changed. The old fact is closed at the start point of the new fact; both are retained and linked.
- revise: the world didn't change, only the wording did. The new text inherits the confirmation record of the old text.
- invalidate: no longer true from a certain date, with no replacement.
- confirm: a second source agrees, increasing the fact's weight.
- dispute: two sources conflict; both are kept open and flagged, without forcing a choice.
The value of this primitive set lies in auditability. When an agent makes a decision, you can trace which version of a fact it relied on, how many sources it came from, and whether there are unresolved conflicts—rather than only seeing a final overwritten value.
Bitemporal Queries: valid_at and known_at
The real killer feature of episodic memory is two kinds of temporal queries:
valid_at="2026-03-02": what was true in the world on that day?known_at="2026-03-02": what did the memory know on that day?
These two questions often yield different answers, and traditional vector stores simply can't distinguish them. For example, if a policy takes effect in March but the system only learns of it in April, querying March with valid_at returns the correct fact, while querying March with known_at should return "not yet known at that time." For agent scenarios requiring retrospection or compliance audits, this distinction is quite critical.
Under the hood, CtxVault places a SQLite file inside the vault folder, introducing no additional service dependencies and maintaining its local-first positioning.
Bitemporal modeling is a mature concept in the database field, referring to tracking both the "valid time" of data (the period during which a fact is true in the real world) and the "transaction time" (the moment data is recorded into the system). CtxVault's valid_at and known_at correspond to these two dimensions respectively. This model can precisely answer two kinds of questions: what was true in the world at a given historical point, and what the system knew at a given historical point. The two are often inconsistent—for example, a policy takes effect in March but the system only records it in April. Bitemporality lets agents distinguish "changes in the fact itself" from "lag in cognition," which is especially critical in compliance auditing and post-hoc attribution scenarios.
Integrating with LangGraph: Via MCP, No Custom Glue Code
CtxVault's integration with LangGraph is done entirely through MCP, with no custom adapter layer. The example code uses langchain_mcp_adapters to load tools, starts a stdio MCP server, and hands the tools to create_agent:
from langchain_mcp_adapters.tools import load_mcp_tools
from mcp import ClientSession, StdioServerParameters
from mcp.client.stdio import stdio_client
params = StdioServerParameters(command="ctxvault-mcp", args=["--agent", "support-bot"])
async with stdio_client(params) as (r, w), ClientSession(r, w) as s:
await s.initialize()
tools = await load_mcp_tools(s)
agent = create_agent(ChatOpenAI(model="gpt-4o-mini"), tools)
The --agent parameter is the anchor point for access control: each vault declares which agents can access it, and validation is performed server-side. This means that even if two agents share the same memory folder, they cannot read each other's vaults without authorization. For multi-agent collaboration scenarios, this is a pragmatic security boundary.
MCP (Model Context Protocol) is a standardized protocol proposed and open-sourced by Anthropic for connecting AI applications to external tools and data sources in a unified way. It defines a set of client-server interaction specifications, supporting stdio, HTTP, and other transports. In CtxVault's integration, langchain_mcp_adapters acts as a bridge, automatically converting the tools exposed by the MCP server into LangChain-callable Tool objects, which are then passed to create_agent to build the agent. The benefit of this design is decoupling: the memory layer only needs to implement the MCP interface to be reused by any MCP-compatible host such as LangGraph or Claude Desktop, without writing custom adapter code for each framework.
Interface and Current Status
The UI the author provides is the time cursor shown in the gif—drag it to see what was stored in memory on a given day, in read-only mode. If you don't want to install anything, the project also offers a static snapshot of the same UI that you can click through without a server.
Frankly, CtxVault's current capability boundaries are also clear: no graph memory, no automatic file system sync, and no automatic fact extraction from conversations—the agent decides what to write. The author is still undecided about whether to add an optional extraction layer, since that would let the project be evaluated on benchmarks like LongMemEval. This is a trade-off worth watching: automatic extraction improves usability, but also introduces extraction errors and a gap between benchmark performance and real-world use.
The repository is at github.com/Filippo-Venturini/ctxvault; example 06 is the minimal episodic memory example, and example 05 is the LangChain + MCP integration example.
LongMemEval is a benchmark dataset specifically designed to evaluate long-term memory capabilities, covering task types such as information extraction from multi-turn conversations, multi-session reasoning, temporal reasoning, knowledge updates, and abstention (refusing to answer). It is mentioned here because CtxVault currently doesn't automatically extract facts from conversations and therefore can't be evaluated end-to-end on this benchmark. Adding an automatic extraction layer would allow the project to participate in such benchmark comparisons, but would also introduce new issues such as extraction errors and discrepancies between evaluation metrics and real-world usage scenarios. This trade-off reflects a general tension in agent memory systems between "usability" and "accuracy/auditability."
Some Observations
Agent memory is shifting from "bigger vector stores" to "better temporal semantics." CtxVault's bitemporal design and its approach of preserving conflicts are closer in spirit to temporal dimensional modeling in the database field than to a scaled-up version of retrieval augmentation. For agents that need to run long-term and be explainable after the fact, these kinds of primitives may be more valuable than storing a few million more embeddings.
Related articles

Nvidia CEO Removal Saga: Trump Intervenes Over the Weekend, Jensen Huang Reinstated Monday
Vergecast podcast reveals Nvidia CEO drama: earnings call said he wouldn't return and a new CEO was being sought; Trump intervened over the weekend, with J.D. Vance brokering a security guarantee to the board; Jensen Huang reinstated at 9 a.m. Monday.

Semantic Caching Explained: Reusing the Same Answer for Similar Questions
Semantic caching uses embeddings to judge whether queries are similar in meaning and reuses cached results for similar prompts. This article explains how it works, the difficulty of threshold tuning (such as the risk of misjudging negations), and its applicable boundaries.

How Did Trump Personally Turn Nvidia into the "Twelfth Board Member"?
A YouTube political commentary offers a sharp view: behind Nvidia's market cap milestone, Trump's deep involvement earns him the title of "twelfth board member." The article breaks down the commentator's logic on stock market achievements, the break from small-government tradition, and power display.