Agent memory

Agent memory

InvariantDB stores an agent's events, beliefs and decisions in a graph. Each fact has a valid time and a recorded time, so you can query what the agent knew when it acted.

Start free Read the docs
Example: to see what the agent knew at 15:47 on 13 April 2026, add AT RECORDED '2026-04-13T15:47:00Z' to the MATCH.

Agent memory features

Memory features built into the database.

Persistent

Outlives context windows and process restarts. State lives in the graph, not in the agent process.

Queryable

Real graph structure: entities, facts, sessions, contradictions. Query with Cypher.

Temporal

Bitemporal by default. Replay agent memory state at any past moment with AT RECORDED.

Auditable

Committed node and relationship writes are appended to a hash-chained history. Add a provenance object to a write to record the acting agent and the reason; the server also records the credential that made it. WORM mode is available under an Enterprise license: updates and deletes sent through Cypher, MCP tools, /execute and import are refused. It does not cover the legacy POST /write route on the default graph, schema or index changes, or an administrator dropping the whole graph.

Shared

Several agents can read and write the same graph, so one agent's findings inform another's. Limit each agent's API key to the graphs it should reach.

From code

npm install https://sdk.invariantdb.com/node/invariantdb-0.8.0.tgz — the client runs the memory procedures through Cypher.

import { Client } from "invariantdb"; const c = new Client({ url: "https://invariantdb.com", apiKey }); const g = "agent-memory-support-bot"; // Record an event in the session log await c.cypher(g, "CALL db.recordEpisode($s, 'UserMessage', $text) YIELD eventId, ts RETURN eventId, ts", { parameters: { s: sessionId, text } }); // Replay the session, oldest first await c.cypher(g, "CALL db.replayEpisodes($s, 50) YIELD kind, ts, text RETURN kind, ts, text", { parameters: { s: sessionId } }); // What did the graph hold at this moment? await c.cypher(g, "MATCH (e:Event) AT RECORDED '2026-04-13T15:47:00Z' WHERE e.text CONTAINS $q RETURN e.text", { parameters: { q: "refund" } });

Ranked recall over HTTP (keyword or vector search plus hop expansion): POST /graphs/{graph}/memory/recall with {"query": "...", "k": 10, "hops": 1}.

Use agent memory over MCP

Agents that support the Model Context Protocol can use the same graph without the SDK. remember saves a memory, recall finds memories by keyword, recall_as_of lists memories as of a past time, and record_episode and replay_episodes write and read a session log. save_document and get_document keep versioned documents. The endpoint is https://invariantdb.com/graphs/{graph}/mcp. See the MCP page for setup.

Related features

Schema suggestions are available through the HTTP API. The investigation endpoints are deprecated.

Available

Schema suggestions

Suggests index and schema changes for a graph.

  • POST /graphs/{name}/suggestions/sweep checks for missing indexes, unused labels and schema drift.
  • POST /graphs/{name}/suggestions/analyze checks one Cypher query against the graph’s indexes.
  • GET /graphs/{name}/suggestions lists suggestions; POST /graphs/{name}/suggestions/{key}/apply applies one.
Retired

Investigation endpoints

The natural-language query, investigation and agent endpoints (/graphs/{name}/nlq, /graphs/{name}/investigate and /graphs/{name}/agent) are retired: from 1.4.3.3 they answer HTTP 410 with subcode FEATURE_RETIRED and call no model. Natural-language questions and agent runs move to the knowledge-graph product; run Cypher with POST /graphs/{name}/cypher. The memory tools (remember, recall, save_document) are not affected. GET /graphs/{name}/cases stays for reading recorded cases, is deprecated, and serves a case only to the credential that recorded it or to a global administrator holding the same roles.

Access control and audit

Give each agent its own graph and an API key whose graphs list names only that graph. A compromised key can then reach only that graph.

One graph per agent

Each agent can use its own graph. A key with a graphs list reaches only the graphs it names; a key without one can reach any graph its tenant allows.

API key scoping

Each key has a tenant, a role and an optional graphs list, checked on each request.

Concurrency limit

Each named graph accepts a limited number of concurrent queries. Extra requests are refused with HTTP 503 (MCP error -32000) and a suggested retry delay.

Key expiry

Set ttlDays when you create a key for an agent; a key created without it does not expire. An admin can rotate a key with POST /admin/api-keys/{id}/rotate, which revokes the old key.

Actor attribution

Send provenance with a Cypher write, for example {"actor": "agent:support-bot", "reason": "refund approved"}, as the MCP cypher_query argument, an HTTP body field, or X-Provenance-* headers. The server adds the calling credential as principal. Read both with CALL db.propertyProvenance(...).

Version history

A write creates a new version instead of overwriting the old value. Read earlier values with AT RECORDED or CALL db.propertyHistory(...).

Start with a free account

Create an API key, then install the SDK or connect over MCP.

npm install https://sdk.invariantdb.com/node/invariantdb-0.8.0.tgz