# Memory manager

What agents remember about this account, one line each, with who taught it and when. Things an agent inferred are marked as inferred, so a person can confirm or delete them; things a person said are theirs. Add a memory in plain words. Memory agents take from past chats can't be listed, so with `history` it says so plainly, and an empty list never reads as "nothing remembered". With `mode` it says when memory is paused or off.

- Registry name: `memory-manager` (`@candor/memory-manager`)
- Tier: Pro. Installing it needs a Pro, Premium or Team licence key: the person runs `npx candor-ui key <key>` themselves; never ask for the key in chat or write it to a file.
- Docs: https://candor.themethodic.com/docs/memory-manager

## Install

```bash
npx candor-ui add memory-manager
```

Run `npx candor-ui@latest init` once first (https://candor.themethodic.com/get-started.md). Without the CLI: `npx shadcn@latest add @candor/memory-manager`.
It brings in: agent-avatar, button, know, locale, relative-time, terms, utils.
npm packages: lucide-react@^1.67.0.

## Example

```tsx
"use client"

import * as React from "react"
import type { Memory } from "@/lib/know"
import { MemoryManager } from "@/components/memory-manager"

const ago = (h: number) => new Date(Date.now() - h * 3_600_000).toISOString()

const initial: Memory[] = [
  { id: "m1", text: "Staging is reset from a Production snapshot every Monday at 06:00.", from: { person: "Dana" }, createdAt: ago(24 * 6), scope: "environment", environmentId: "staging" },
  { id: "m2", text: "Priya approves anything touching data regions or routing.", from: { person: "Maya" }, createdAt: ago(24 * 20), scope: "account" },
  { id: "m3", text: "The team prefers enums to free-text columns for anything reported on.", from: { agent: { id: "a-arch", name: "Architect agent", role: "architect" } }, createdAt: ago(48), scope: "account" },
]

export default function Example() {
  const [memories, setMemories] = React.useState(initial)
  return (
    <MemoryManager
      className="max-w-xl"
      memories={memories}
      history={{ chats: 14 }}
      onAdd={(text) => setMemories((l) => [{ id: `m${Date.now()}`, text, from: { person: "You" }, createdAt: new Date().toISOString(), scope: "account" }, ...l])}
      onDelete={(id) => setMemories((l) => l.filter((m) => m.id !== id))}
      onConfirm={(id) => setMemories((l) => l.map((m) => (m.id === id ? { ...m, from: { person: "You" } } : m)))}
    />
  )
}
```

## <MemoryManager>

Props:

- `memories: Memory[]`: What's remembered, with who taught it (a person or an agent) and when.
- `onAdd?: ((text: string) => void) | undefined`: Shows a box to add a memory; called with its text.
- `onDelete?: ((id: string) => void) | undefined`: Shows Delete on each memory; called with its id.
- `onConfirm?: ((id: string) => void) | undefined`: Turn an inferred memory into one the viewer stands behind.
- `history?: { chats?: number | undefined } | undefined`: Agents also learn from past chats, which can't be listed: says so, with how many chats if known.
- `mode?: MemoryModeValue | undefined`: Whether memory is on, paused or off (see MemoryMode). Paused and off are said above the list.
- `className?: string | undefined`

## Strings (`memoryManager`)

The fixed words, English by default. Override any of them under `memoryManager` in `<LocaleProvider strings={{ memoryManager: { … } }}>`; the table is exported as `memoryManagerStrings`.

- `label`: Memory
- `heading`: What agents remember
- `summary`: {total} · {inferred} inferred
- `placeholder`: e.g. Staging is refreshed every Monday morning
- `newMemory`: New memory
- `add`: Add
- `empty`: Nothing remembered yet.
- `emptyWithHistory`: No saved memories.
- `history`: Agents also learn from past chats. That isn’t kept as a list, so it can’t be shown or forgotten one by one here.
- `historyCount`: { one: "Agents also learn from {count} past chat. That isn’t kept as a list, so it can’t be shown or forgotten one by one here.", other: "Agents also learn from {count} past chats. That isn’t kept as a list, so it can’t be shown or forgotten one by one here.", }
- `paused`: Memory is paused. These are kept as they are; agents don’t use them until it’s back on.
- `off`: Memory is off. Agents don’t use these.
- `inferredBy`: Inferred by {name}
- `from`: From {name}
- `environmentOnly`: this {environment} only
- `confirm`: Confirm
- `forgetThis`: Forget this
- `forget`: Forget

## Rules for using Candor UI

- Components take plain typed data. Never pass model output as HTML or render it as a link; messages are typed blocks.
- A control that can't be used says why: wrap it in `<Locked reason="…">`, don't just disable it.
- Don't show a value you don't have: leave it out (it renders as —) rather than guess. An estimate is labelled as one.
- Nothing is pre-selected in a decision a person makes, and the agent is named from your app's data, never from model output.
- Your app's words go in `LocaleProvider` (fixed strings) and `TermsProvider` (nouns); entity kinds and agent roles in `EntityKindsProvider` and `AgentRolesProvider`.
