> ## Documentation Index
> Fetch the complete documentation index at: /docs/llms.txt
> Use this file to discover all available pages before exploring further.

# Remember users between sessions

> Have your agent keep facts about each user between sessions, stored encrypted on Jaccard. Let users ask to be forgotten, and expire memory nobody uses.

Each file in `agent/memory/` is one memory slot, named after the file. eve's file memory keeps one short document per scope, such as each signed-in user, and the model saves and removes entries with tools. On Jaccard, use `jaccardFileMemory()` from `@jaccard-ai/world`. It's eve's file memory kept on Jaccard, with one more tool the model calls when a user [asks to be forgotten](#let-users-ask-to-be-forgotten):

```bash theme={"theme":{"light":"github-light","dark":"github-dark"}}
pnpm add @jaccard-ai/world@^0.2.3
```

```ts agent/memory/customer.ts theme={"theme":{"light":"github-light","dark":"github-dark"}}
import { defineMemory } from "eve/memory";
import { byPrincipal } from "eve/memory/scope";
import { jaccardFileMemory } from "@jaccard-ai/world/memory/file";

export default defineMemory({
  description: "Stable facts and preferences about the person you are talking to.",
  // Fixed, so memory follows the agent across builds and machines.
  // Changing it orphans everything remembered so far.
  // Each slot needs its own, so this one names the slot.
  namespace: "my-agent/customer",
  provider: jaccardFileMemory(),
  scope: byPrincipal,
});
```

An agent with one slot can keep it in `agent/memory.ts` instead, as a slot named `memory`. eve refuses a project that has both that file and an `agent/memory/` directory, so move the file into `agent/memory/` before you add a second slot.

eve finds each document by a key it derives from the slot's `namespace` and the scope. Choose the `namespace` once: after you change it, the agent no longer finds anything the slot remembered.

> [!WARNING]
>
> Give each slot a `namespace` of its own. With a `namespace` set, the slot's name isn't part of the key, so two slots with the same `namespace` and scope share one document: their facts merge, and a user who asks one slot to forget them loses the other's memory too.

With `byPrincipal`, each signed-in user has their own document in each slot, so alice's facts are never recalled for bob. A caller who isn't signed in has no memory: the agent saves and recalls nothing for them. If your web app or service calls the agent, it has to name each user, or they all share one memory: see [Let a service call on behalf of its users](/docs/operate/access.md#let-a-service-call-on-behalf-of-its-users).

> [!WARNING]
>
> eve's docs show `fileMemory()` with no backend, which stores to Vercel Blob. On Jaccard, every turn that uses the slot then fails with this error, though the agent works under `pnpm dev`:
>
> ```text theme={"theme":{"light":"github-light","dark":"github-dark"}}
> fileMemory() requires an explicit backend outside Vercel and eve dev. Pass fileMemory({ backend }).
> ```
>
> Write the slot file yourself rather than with `eve add memory/file`, whose setup creates Vercel Blob storage that Jaccard doesn't use.

`fileMemory({ backend: jaccardMemory() })`, with `jaccardMemory` from `@jaccard-ai/world/memory`, still works. It has no tool for forgetting.

## Let users ask to be forgotten

`jaccardFileMemory()` gives the model a tool named `<slot>__forget_everything`, here `customer__forget_everything`. The model calls it when a user asks to be forgotten or to have what the agent remembers about them erased.

* It deletes what the slot has saved for the current user: the document of the current scope. Other users keep theirs, and so do other slots with a `namespace` of their own.
* With a scope several users share, such as one per Slack channel, it clears that memory for all of them.
* From the user's next message, the agent no longer recalls the deleted memory. You can't restore it.
* It runs only in that user's own session. Nothing deletes a named user's memory from outside one.

It doesn't reach:

* **Conversation history:** this conversation and the user's earlier ones still hold what the user said.
* **Memory under an earlier `namespace`:** what the slot saved before you set or changed its `namespace`, or before you renamed a slot that had none. That memory stays stored, counts toward the agent's [limit](#where-memory-is-kept) and appears in a [list or an export](#list-export-and-import-memory). It goes when it [expires](#expire-memory-nobody-uses), when the agent's code deletes it by key, or when you delete the agent.

## Expire memory nobody uses

Memory is kept until you ask for it to expire. To have Jaccard delete a document that goes unused, set `expireAfterDays`, on `jaccardFileMemory()` or `jaccardMemory()`:

```ts theme={"theme":{"light":"github-light","dark":"github-dark"}}
provider: jaccardFileMemory({ expireAfterDays: 90 }),
```

* A document is deleted between 90 and 91 days after the agent last saved to it or recalled it, never sooner.

* [Listing and exporting](#list-export-and-import-memory) don't count as use.

* The setting reaches a document the next time the agent saves to it. A document saved before you set `expireAfterDays` doesn't expire until then, and one saved after you remove it stops expiring.

* `expireAfterDays` is a whole number from 1 to 3,650. Any other value throws when the slot loads:

  ```text theme={"theme":{"light":"github-light","dark":"github-dark"}}
  @jaccard-ai/world: expireAfterDays must be a whole number of days from 1 to 3650
  ```

* Nothing expires under `pnpm dev`.

> [!WARNING]
>
> You can't restore expired memory.

To see how often the agent recalls memory and how many recalls fail, open its [**Metrics** tab](/docs/operate/metrics.md#count-memory-recalls) in the console.

## Where memory is kept

* Memory belongs to the agent. No other agent can read it, including others in your organization.
* It's kept across sessions, restarts, idle stops and deploys. Nothing expires unless you [ask](#expire-memory-nobody-uses).
* Each document is encrypted with the agent's key before it leaves the agent, and the platform stores only the ciphertext. The console and the CLI can't show or clear it. In a slot that uses `jaccardFileMemory()`, a user clears their own by [asking the agent](#let-users-ask-to-be-forgotten). The agent's code can [list, export and delete](#list-export-and-import-memory) it.
* eve's limits on the size of an entry and a document apply, as [eve's file memory documentation](https://eve.dev/docs/memory/file#how-it-behaves) lists them.
* An agent can hold a limited number of memory documents: one per scope in each slot, so with `byPrincipal` one per user who has saved anything. Your organization has one limit, which applies to each of its agents: see [how many an agent holds](#check-how-many-documents-an-agent-holds). At the limit, a save for a user with no memory yet fails with the error below. Users who already have memory keep it and can still save. To raise the limit, email [support@jaccard.ai](mailto:support@jaccard.ai).

  ```text theme={"theme":{"light":"github-light","dark":"github-dark"}}
  @jaccard-ai/world: this agent holds the most memory documents it may; the platform refused a new one
  ```

> [!WARNING]
>
> Deleting the agent or its organization deletes its memory. An agent you create again with the same name starts with empty memory.

Jaccard meters stored agent memory. See [Hourly usage](/docs/operate/usage.md#hourly-usage) for the **Managed agent memory** chart.

## List, export and import memory

The backend that `jaccardMemory()` returns lists and deletes the agent's documents, and `exportMemory` and `importMemory` move them. Call them from the agent's own code, such as a TypeScript schedule, because only the running agent holds the key that decrypts its memory.

```ts theme={"theme":{"light":"github-light","dark":"github-dark"}}
import { exportMemory, jaccardMemory } from "@jaccard-ai/world/memory";

const backend = jaccardMemory();

// Each document's key, version, stored size and last save. Never its content.
for await (const { key, bytes, updatedAt } of backend.list()) {
  console.log(key, bytes, updatedAt.toISOString());
}

// Every document, decrypted.
const documents = [];
for await (const { key, content } of exportMemory(backend)) {
  documents.push({ key, content });
}
```

> [!WARNING]
>
> An export holds every user's memory in plaintext, and it stays plaintext until you import it. If a route or a job serves an export, put your own authentication in front of it, and never offer it to the agent's users.

An export doesn't say whose a document is. Each `key` is the opaque key eve derives from the slot's `namespace` and the scope, not a user's name or ID.

`backend.delete` removes one document by the key `list` gave. Use it to remove a document the agent no longer finds, such as one left under an earlier `namespace`. You can't restore a deleted document.

```ts theme={"theme":{"light":"github-light","dark":"github-dark"}}
// Resolves to false when no document has that key.
const deleted = await backend.delete({ key, signal: AbortSignal.timeout(10_000) });
```

`importMemory(backend, documents)` writes each `{ key, content }` in order and resolves to `{ imported, skipped }`:

* It checks each document against eve's file memory format before it writes it. A document that fails stops the import with an error that names the key and the reason. The documents before it stay written.
* It skips a document whose key already exists. To replace existing documents, pass `{ overwrite: true }` as the third argument.
* The agent recalls an imported document only when the slot's `namespace` and scopes are the same as where it was exported.
* An imported document is encrypted with the key of the agent that runs the import, and only that agent can read it. To move memory to another agent, export it in the first and run the import in the second.
* An imported document takes `expireAfterDays` from the backend you import with, not from where it was exported. Pass the slot's value, such as `jaccardMemory({ expireAfterDays: 90 })`.

## Check how many documents an agent holds

The agent's **Overview** in the [console](/docs/operate/console.md) shows **Memory documents** against your organization's limit, such as `1,204 of 100,000`. The number changes color at 80% of the limit, and again at the limit. The console's **Usage** page lists the limit as **Memory documents per agent**.

* The platform counts about every 10 minutes, so a save can take up to about 20 minutes to show.
* An agent that holds no memory documents has no **Memory documents** line. The line appears after the first count that follows the agent's first save.
* The count is every document stored under the agent's name. After you delete an agent and create it again with the same name, the count can include the deleted agent's documents until the platform deletes them. The new agent can't read them, and they don't count toward its limit.

## Deploy with the platform world

Memory is kept by the platform's [workflow world](/docs/operate/deploy.md#the-workflow-world), which `jaccard deploy` uses unless you pass `--local-world`. On an agent deployed with `--local-world`, every turn that uses memory fails with:

```text theme={"theme":{"light":"github-light","dark":"github-dark"}}
@jaccard-ai/world: JACCARD_WORKFLOWS_ENDPOINT is not set; memory needs the platform world (spec.world: platform) outside eve dev.
```

To fix it, set up the world as that section shows and deploy without `--local-world`.

Under `pnpm dev`, memory never reaches Jaccard, even when the platform's variables are set. It's kept unencrypted in `.eve/jaccard/memory.json` in the project.

* A slot with a fixed `namespace` keeps its memory when you restart `pnpm dev`. A slot without one starts empty on each restart.
* eve gives each local `eve eval` run a state directory of its own in place of `.eve`, so an eval starts with empty memory.
* Forgetting, listing, deleting, exporting and importing work on the file.
* Run one `pnpm dev` per project. Two on the same project overwrite each other's memory.

> [!WARNING]
>
> Keep `.eve/` in `.gitignore`. The memory file is plaintext, and `jaccard deploy` uploads the files that `.gitignore` doesn't exclude. A project `jaccard init` created already ignores it. One you set up by hand may not.

## Keep memory readable when you change the agent

These changes can leave the agent's existing memory unreadable:

* **Upgrading eve:** before you move an agent that has memory to a new eve version, read eve's release notes for a change to the memory file format or to how memory keys are derived.
* **Setting or changing `namespace`:** the slot starts empty, including when you add a `namespace` to a slot that had none. The earlier documents stay stored and still count toward the agent's limit, and the agent finds them again if you restore the earlier value.
* **Renaming a slot without a `namespace`:** the slot's file name is part of its keys, so renaming the file starts that slot empty.
* **Your own Dockerfile, for a slot without a `namespace`:** the directory the agent was built in is part of its keys. If you deploy with a Dockerfile you wrote or edited, keep running `eve build` in the same directory. The generated Dockerfile and the platform's own builds use `/app`.

## Use another memory provider

eve's other providers, such as Supermemory and Upstash AgentKit, and providers you write keep memory in their own store, so they work on Jaccard as they do anywhere. Set their keys with `jaccard env add`. They don't need `@jaccard-ai/world/memory`.

eve's [memory documentation](https://eve.dev/docs/memory) goes further, such as sharing one memory per Slack channel and telling the model what to save.


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.