Skip to main content

Memory

In one sentence

Memory is what lets your agent remember things — like a good assistant who knows your name, recalls what you discussed last week, and doesn’t ask you the same question twice. By default, an AI model forgets everything the moment a conversation ends. Memory fixes that.
The 30-second version: Add a memory block to your agent, point it at a database, and your agent now remembers users across conversations — automatically. No extra code. Everything else on this page is optional fine-tuning.

Why it matters

Think about the difference between two customer-service experiences:
  • Without memory: “Hi, can I get your name? And your order number? And what was the issue again?” — every single time, even if you called yesterday.
  • With memory: “Hi Akash — is this about the delayed order ORD-7421 we discussed yesterday? I see it shipped this morning.”
The second one feels like a relationship. That’s memory. It’s the difference between a chatbot people tolerate and an assistant people trust.

The mental model

Think of memory as a smart filing cabinet that sits behind your agent:
  • Every conversation, the agent opens the relevant drawers before answering (“what do I know about this person?”).
  • After the conversation, it files away anything new it learned (“they mentioned they prefer email”).
  • The cabinet has separate drawers for separate things — one for chat history, one for facts about the person, one for company knowledge, and so on.
  • Each person’s drawers are private — your data never shows up in someone else’s folder.
The rest of this page explains what’s in each drawer and how to configure them. But you can start with just one line: a storage backend.

Quick Start

With just storage, you get:
  • Session persistence — message history saved across runs
  • Summaries — overflow messages automatically summarized

Full Configuration

Architecture

Memory is a layered subsystem, not a single store. One orchestrator (MemoryManager) coordinates up to nine specialized stores, each owning its own schema, extraction prompt, and scope rules, all sitting on a shared StorageDriver.
Each layer talks to the next only through a typed interface — swap MongoDB for Postgres, or Qdrant for Pinecone, without touching any store logic.

The nine “drawers” (stores)

Each store is one drawer in the filing cabinet. You turn on the ones you need. You don’t need all of them. Most agents use Sessions + Summaries (on by default) plus User Facts. Turn on the rest only when your use case calls for it — the table later in this page tells you when.
Rule of thumb:
  • Want the agent to remember the person → turn on User Facts.
  • Want it to remember the conversationSessions + Summaries (already on).
  • Want a team to share knowledge → turn on Learnings or Procedures (see Scope Hierarchy).

How It Works

Every time your agent answers, two things happen automatically — like an assistant glancing at their notes before speaking, then jotting down anything new afterward:
  1. Before answering → the agent reads its memory and brings the relevant bits into the conversation.
  2. After answering → the agent quietly files away anything new it learned.
You write zero code for either. Here’s what’s happening under the hood.

1. Before the answer: gather what we know (buildContext())

MemoryManager.buildContext() gathers relevant data from all enabled stores and creates a context string injected into the system prompt:
This context is appended to the system prompt, giving the model persistent awareness across sessions.

2. After the answer: remember what’s new (afterRun())

The user already has their answer — so this step runs in the background and never slows down the response. It quietly re-reads the conversation (using a cheaper model to keep costs low) and files away anything worth remembering:
  • New user facts and profile updates
  • Entity mentions (companies, people, projects)
  • Decision records
  • Learnings worth remembering

3. Keeping it from getting too big (session overflow)

A conversation can’t grow forever — that would blow past the model’s limits and cost. So when a chat gets long (past maxMessages), the oldest messages are summarized into a short recap and then removed. The agent keeps the gist without carrying every word. Think of it as turning ten pages of notes into a single sticky note.

Works Everywhere

The same memory config works across all agent types:

Simplified API

For quick operations without dealing with individual stores, use the high-level remember, recall, and forget methods:
See Simplified API for full details.

Default Feature States

Accessing Stores Directly

You can access individual stores via the MemoryManager:

Inspecting Memory Context

You can call buildContext() directly to see what the model receives:
Each section is wrapped in an explicit scope marker so the LLM never conflates user/session/agent data:
This is useful for debugging — if the model seems to “forget” something, check if the relevant store is enabled and producing context.

Multi-User Isolation

The short version: one user’s memory never leaks into another user’s conversation. Akash’s data stays in Akash’s drawers. This is enforced automatically — you don’t have to do anything to get it. This matters because the moment you have more than one user (every real product), a memory system that mixes people’s data is a privacy incident waiting to happen. Agentium treats memory as a security boundary, not just a feature. Every memory store is scoped to the calling user by default. Two tenants whose users happen to share a userId collision still cannot see each other’s data, because every read and write includes the relevant scope key. Learnings and Procedures support an explicit scope hierarchy so that genuinely shared knowledge — like “invoice reconciliation workflow” or “refunds > $500 need VP approval” — can be saved once and seen by every authorised user. See Multi-User Isolation for the full contract and a worked example. When you call MemoryManager.buildContext(sessionId, userId, ...) without a userId, stores that require one return empty strings rather than risk surfacing another user’s data.

Observability

Memory subsystem failures emit events on the agent’s EventBus so they don’t silently disappear. The most useful one is memory.error:
Other memory events:
  • memory.fact.added / memory.fact.invalidated — fact-store mutations.
  • memory.extract — background extraction triggered.
  • memory.context.builtbuildContext returned (with totalTokens and per-section breakdown).
These are first-class members of AgentEventMap, so you can wire them into @agentium/observability and graph extraction failure rates over time.

Cross-References