# Supermemory in Chats (/docs/supermemory)

Tavern Cozy uses [Supermemory](https://supermemory.ai) as the memory service behind
chats. This page describes what the integration does in the app and what it costs.

<Callout type="info">
Supermemory's own documentation index is
[supermemory.ai/docs/llms.txt](https://supermemory.ai/docs/llms.txt). Read it when
you need detail about the service itself.
</Callout>

## The three steps in a chat [#the-three-steps-in-a-chat]

1. **Ingest.** After a turn, the conversation text is added to Supermemory with
   metadata for the user, the character, the persona, and the chat.
2. **Retrieve.** Before a reply is written, the app searches the user's namespace
   with a filter, and reads the memory profile.
3. **Use.** The retrieved context and the profile are placed in the prompt next to
   the persona and the lorebook entries.

Ingest runs in the background. A chat that ended a moment ago can still be missing
from search until the pipeline finishes.

## Namespace and filters [#namespace-and-filters]

- Every account has its own **namespace**, derived from the user id. A search never
  crosses into another account's namespace.
- A search is scoped by `characterId`, plus `personaId` when a persona is selected.
  That is why two characters do not share one memory, and why switching a persona
  changes what is recalled.
- A single chat can also be scoped by `chatId`, which is how a per-chat setting
  stays per chat.

## What it costs [#what-it-costs]

Memory is metered like any other provider call:

| Operation | Billing basis |
| --- | --- |
| Ingest a turn | Tokens sent |
| Search for context | Per search |

The charge is recorded on the account that owns the chat, so a memory search is a
line in the usage view. A truly zero-cost call stays free.

If `SUPERMEMORY_API_KEY` is not set on the server, the integration makes no call,
spends nothing, and charges nothing. A chat then runs without memory and nothing
else changes.

See [Credits and plans](/docs/credits) for the balance rules and the refund rule.

## Deleting memory [#deleting-memory]

- Deleting a message removes the documents written for it.
- Deleting a chat removes every document that belongs to the chat in your
  namespace.
- A delete is namespace-scoped and takes document ids. A delete that conflicts
  with an ingest still in progress is retried.
- Turning memory off for a chat stops retrieval for that chat. Content that was
  already ingested stays in the namespace until the chat is deleted.
- Account deletion removes the account's content, including its memory namespace.

## What can go wrong [#what-can-go-wrong]

- **A detail is missed.** Retrieval is semantic and best effort. A wording that
  does not match returns nothing.
- **The profile is out of date.** The profile is maintained from ingested content,
  so it lags a fresh conversation.
- **A provider outage is silent to the chat.** The reply is written without memory
  rather than failing the send.

None of these are reasons to trust memory as the only copy of a fact. Put the rules
of the world in a [lorebook](/docs/lorebooks) and the fixed details in a
[persona](/docs/personas).