Skip to main content

Memory

The Memory feature gives each bot persistent, long-term memory that survives across sessions. Bots can remember facts, preferences, and context between conversations without you repeating yourself.

How It Works

Each bot has its own isolated memory store backed by IndexedDB. Memory entries are key-value pairs that persist in the browser across page reloads and sessions.

When a bot has memory entries, they are automatically injected into the system prompt before each message is sent. The model receives the stored context as part of its instructions, giving it access to remembered information without consuming visible chat history.

Injection Format

The injected format uses XML-style <memory> tags prepended to the system prompt:

<memory>
- user_name: Alice
- preferred_language: Python
- project: Building a REST API with FastAPI
</memory>

Each entry is rendered as - key: value on its own line inside the <memory> block. If a bot has no memory entries, nothing is injected and the system prompt is sent as-is.

info

Memory injection adds to the system prompt length, which counts toward the model's context window. If you have many memory entries, they consume tokens that could otherwise be used for conversation history. Keep entries concise.

Adding Memories

Automatic via bcz_remember()

The primary way memories are created is through the model's own output. When a model includes a bcz_remember() call in its response, the platform automatically parses and stores the memory entry.

The tool-call pattern the model uses:

bcz_remember("user_name", "Alice")

The platform scans every assistant response for this pattern using a regex matcher:

bcz_remember("key", "value")

Multiple bcz_remember() calls can appear in a single response -- all are parsed and stored. This allows the model to autonomously decide what information is important enough to remember for future conversations.

Example conversation:

You:  My name is Alice and I prefer Python with type hints.
Bot: Nice to meet you, Alice! I'll remember your preferences.
bcz_remember("user_name", "Alice")
bcz_remember("preferred_language", "Python")
bcz_remember("coding_style", "type hints")

After this exchange, the three memory entries are stored and will appear in the <memory> block on all future messages to this bot.

tip

You can explicitly ask the bot to remember something: "Remember that I prefer concise answers" or "Save my timezone as US/Pacific." Models that support tool calling will typically respond with the appropriate bcz_remember() call.

Manual Management in Settings

You can also manage memories directly:

  1. Open Settings
  2. Navigate to the Memory section for the current bot
  3. Add, edit, or remove individual memory entries

Each entry shows its key, value, and timestamp (when the entry was last created or updated).

Editing and Deleting Memories

From the Memory panel in Settings:

  • Edit any memory entry by changing its key or value
  • Delete individual entries with the remove button
  • Clear all memories for the current bot
warning

Deleting a memory is permanent. There is no undo. If you clear all memories, the bot starts fresh with no remembered context.

Memory Entry Format

Memories are stored as objects with three fields:

FieldDescriptionExample
kKey -- the identifieruser_name
vValue -- the stored informationAlice
tsTimestamp -- milliseconds since epoch1708300000000

When a key is written that already exists, the existing entry is updated in place (value and timestamp are replaced). This means calling bcz_remember("project", "New project") overwrites any previous project entry rather than creating a duplicate.

Suggested Key Conventions

KeyValueUse Case
user_nameAlicePersonalize responses
preferred_languagePythonCode generation preference
timezoneUS/PacificTime-aware responses
projectFastAPI REST APIOngoing project context
coding_stylePEP 8, type hints, docstringsCode style preferences
response_styleconcise, no fluffCommunication preference
tech_stackReact, TypeScript, TailwindDevelopment environment

Keys should be descriptive and concise. Values can be any text string.

Per-Bot Isolation

Memory is per-bot -- each bot has its own independent memory store. Memories do not leak between bots. This means:

  • Your coding assistant remembers your tech stack
  • Your writing assistant remembers your writing style
  • Neither one sees the other's memories

The storage key is ais-memory-{botId}, where botId is the unique identifier for each bot session. Switching between bots loads only that bot's memory into the cache.

Storage Details

PropertyDetail
BackendIndexedDB (ais-memory-{botId} per bot)
In-memory cacheEntries are cached in a JS object for fast access after first load
PersistenceSurvives page reloads, browser restarts, and session switches
ScopeLocal to your browser -- never sent to any server
ExportIncluded in "Export All Data" backup
Shared URLsMemory is NOT included in shared bot URLs
FormatArray of {k, v, ts} objects stored as JSON

Use Cases

  • Personal preferences -- name, timezone, coding language, communication style
  • Project context -- current project details, tech stack, requirements
  • Recurring instructions -- "always format code with comments", "prefer concise answers"
  • Domain knowledge -- store facts the bot should always know about your environment
  • Conversation summaries -- let the bot maintain a running summary of past discussions
tip

Start with a few key memories (your name, preferred language, project name) and let them grow naturally. The bot becomes more useful as it accumulates context about your preferences and workflows.

How Memory Differs from System Prompts

AspectMemorySystem Prompt
Who writes itThe model (via bcz_remember()) or you (manual)You (in the config panel)
When it changesDynamically, as the conversation evolvesOnly when you edit it
ScopePer-bot, accumulates over timePer-bot, fixed until edited
Content typeKey-value factsFree-form instructions
Shared in URLNoYes

Both memory and system prompts are sent to the model together. The memory block is prepended to the system prompt, so the model sees remembered facts first, followed by your behavioral instructions.

Technical Details

The Memory module (AIS.Memory) exposes seven functions:

FunctionPurpose
init(botId)Load memory entries from IndexedDB into the in-memory cache
get(botId)Return a copy of all memory entries for a bot
set(botId, key, value)Add or update a memory entry (persists immediately)
remove(botId, key)Delete a single memory entry by key
clear(botId)Delete all memory entries for a bot
toSystemPrompt(botId)Generate the <memory> block string for system prompt injection
parseToolCall(text)Extract bcz_remember() calls from assistant response text

The module uses lazy initialization -- it only loads from IndexedDB on first access per bot, then serves from an in-memory cache for the rest of the session. Writes are persisted immediately to IndexedDB via AIS.Storage.set().