Skip to main content

Simplified API

The MemoryManager exposes three high-level methods — remember, recall, and forget — that act as a facade over all enabled memory stores. Use them when you want quick, store-agnostic memory operations without reaching into individual stores.
const mm = agent.memory; // MemoryManager

await mm.remember("User prefers weekly digests", { userId: "u-42" });

const results = await mm.recall("digest preferences", { userId: "u-42" });

await mm.forget({ userId: "u-42", factId: "fact-abc" });

remember

Store a piece of information. The method dispatches to the appropriate store based on the options you provide:
ConditionTarget Store
userId provided and userFacts enabledUserFacts.addFacts
learnings enabled (no userId or userFacts disabled)LearnedKnowledge.saveLearning
entities enabled (fallback)EntityMemory.addFact

Signature

async remember(
  content: string,
  opts?: {
    userId?: string;
    scope?: string;
    importance?: number;
  },
): Promise<void>

Parameters

ParameterTypeDescription
contentstringThe information to store
opts.userIdstringRoutes to user-scoped facts when provided
opts.scopestringNamespace or context label (used as namespace for learnings)
opts.importancenumber0–1 importance weight, affects recall ranking

Examples

// Store a user-scoped fact
await mm.remember("Prefers dark mode", {
  userId: "user-42",
  importance: 0.8,
});

// Store a general learning (no userId → goes to LearnedKnowledge)
await mm.remember(
  "Refunds for delays over 5 days should be auto-approved per policy",
  { scope: "support" },
);

// Fallback to entity memory
await mm.remember("Project Atlas launched Q1 2025");

recall

Search across all enabled stores, apply composite scoring, and return ranked results.

Signature

async recall(
  query: string,
  opts?: {
    userId?: string;
    topK?: number;
    scope?: string;
  },
): Promise<ScoredMemory[]>

Parameters

ParameterTypeDefaultDescription
querystringNatural-language search query
opts.userIdstringInclude user-scoped facts in the search
opts.topKnumber10Maximum results returned
opts.scopestringReserved for future scope filtering

Return type

interface ScoredMemory {
  content: string;
  score: number;   // 0–1 composite score
  source: string;  // "userFacts" | "entities" | "learnings" | "graph"
}

How recall dispatches

recall fans out to every enabled store in parallel, collects candidates, scores each one, then returns the top-K results sorted by score.
StoreWhat it searchesSemantic signal
UserFactsActive facts for the given userIdSubstring match → 0.8, else 0.2
EntityMemoryAll entities by name matchName hit → 0.9, miss → skipped
LearnedKnowledgeVector similarity searchEmbedding distance → 0.7 baseline
GraphMemoryGraph node searchNode relevance → 0.75 baseline
Each candidate is scored with computeCompositeScore, which blends:
FactorDefault WeightDescription
Semantic similarity0.4How well the content matches the query
Recency0.3Exponential decay with a 30-day half-life
Importance0.3The importance value stored with the item

Examples

// Search across all stores for a user
const results = await mm.recall("shipping preferences", {
  userId: "user-42",
  topK: 5,
});

for (const r of results) {
  console.log(`[${r.source}] (${r.score.toFixed(2)}) ${r.content}`);
}
// [userFacts] (0.87) Prefers express shipping for orders over $100
// [entities] (0.72) FedEx (carrier): Primary carrier for domestic orders
// [learnings] (0.65) International shipments need customs pre-clearance
// Search without a userId — only entity, learnings, and graph stores
const results = await mm.recall("Atlas project status");

forget

Remove memories matching the given criteria. Returns the count of stores cleared.

Signature

async forget(opts: {
  userId?: string;
  factId?: string;
  entityId?: string;
  scope?: string;
}): Promise<number>

Parameters

ParameterTypeDescription
opts.userIdstringTarget user for fact/profile deletion
opts.factIdstringRemove a specific fact (requires userId)
opts.entityIdstringRemove a specific entity
opts.scopestringReserved for future scope-based deletion

Deletion behaviour

InputWhat happens
userId + factIdRemoves that single fact from UserFacts
entityIdRemoves that entity from EntityMemory
userId alone (no factId/entityId)Clears all facts and profile data for the user

Examples

// Remove a single fact
await mm.forget({ userId: "user-42", factId: "fact-abc" });

// Remove an entity
await mm.forget({ entityId: "entity-xyz" });

// Clear all user data (facts + profile)
const removed = await mm.forget({ userId: "user-42" });
console.log(`Cleared ${removed} store(s)`);

Full Example

import { Agent, MongoDBStorage, openai } from "@radaros/core";

const agent = new Agent({
  name: "assistant",
  model: openai("gpt-4o"),
  memory: {
    storage: new MongoDBStorage({ uri: "mongodb://localhost/radaros" }),
    userFacts: true,
    entities: true,
  },
});

const mm = agent.memory!;

// Store
await mm.remember("Prefers metric units", { userId: "u-1" });
await mm.remember("Project Orion deadline is March 30");

// Search
const hits = await mm.recall("units", { userId: "u-1", topK: 3 });
console.log(hits);
// [{ content: "Prefers metric units", score: 0.87, source: "userFacts" }]

// Delete
await mm.forget({ userId: "u-1" });

Cross-References