Memory mode

Pro

Whether agents use memory: on, paused or off, with what each does to the memories already kept. Paused never reads as deleted: it says the memories stay. What off does depends on the app, so it says what you tell it (whenOff), and an off that deletes asks first and offers pausing instead. The mode shown is the one the app last reported; while a change is on its way it says so.

Markdown

Preview

Install

With the Candor CLI

First time? Get started sets up the registry and theme. Or with shadcn directly: npx shadcn@latest add @candor/memory-mode

Brings in: button, know, locale, locked, utils

Usage

TSX · The example above
"use client"

import * as React from "react"
import type { MemoryModeValue } from "@/lib/know"
import { MemoryMode } from "@/components/memory-mode"

export default function Example() {
  // The mode shown is the one the app reports; here the "app" reports the change after a moment.
  const [mode, setMode] = React.useState<MemoryModeValue>("on")
  const [count, setCount] = React.useState(12)
  const [pending, setPending] = React.useState(false)
  const change = (next: MemoryModeValue) => {
    setPending(true)
    setTimeout(() => {
      setMode(next)
      if (next === "off") setCount(0)
      setPending(false)
    }, 600)
  }
  return (
    <div className="flex max-w-md flex-col gap-8">
      {/* In this app, turning memory off deletes it, so Off asks first and offers pausing instead. */}
      <MemoryMode mode={mode} whenOff="deleted" count={count} pending={pending} onChange={change} />
      <MemoryMode mode="paused" whenOff="kept" count={12} locked="Your workspace’s policy sets memory for everyone." />
    </div>
  )
}

<MemoryMode>

PropTypeDefaultDescription
modeMemoryModeValue | undefined—The mode the app last reported. Undefined while it hasn't said.
whenOffrequired"kept" | "deleted"—What turning memory off does to existing memories in your app: they're "kept", or "deleted" (asks first).
countnumber | undefined—How many memories are kept now, if known. Shown on paused and off, and in the delete question.
onChange((mode: MemoryModeValue) => void) | undefined—Asks for a change. Show the new mode once the app reports it (`mode`).
pendingboolean | undefinedfalseA change is on its way.
errorstring | undefined—Why the last change failed, if it did. Pass "" for no reason.
lockedstring | undefined—Why memory can't be changed here: a policy, a role.
classNamestring | undefined—Extra classes for the outer element.

Strings

The fixed words, in English by default. Change any of them under memoryMode in <LocaleProvider strings={{ … }}>; the table is exported as memoryModeStrings.

KeyEnglish
labelMemory
onOn
onDetailAgents use what’s remembered and can save new memories.
pausedPaused
pausedDetailAgents don’t use or save memories for now. Existing memories are kept as they are, and used again when memory is back on.
offOff
offKeptDetailAgents don’t use or save memories. Existing memories are kept until you forget them.
offDeletedDetailAgents don’t use or save memories, and existing memories are deleted. This can’t be undone.
kept{ one: "{count} memory kept", other: "{count} memories kept" }
confirmTitleTurn memory off and delete what’s remembered?
confirmCount{ one: "This deletes {count} memory, and it can’t be undone. Pausing keeps it instead.", other: "This deletes {count} memories, and it can’t be undone. Pausing keeps them instead." }
confirmNoCountThis deletes every memory, and it can’t be undone. Pausing keeps them instead.
confirmTurn off and delete
pauseInsteadPause instead
cancelKeep “{mode}”
changingChanging…
failedMemory didn’t change: {reason}
failedNoReasonMemory didn’t change.
unknownNot reported