Memory
Let an agent remember facts about each user across sessions.
Memory lets an agent keep short notes that outlast a single conversation, such as "prefers concise status updates" or "works in the Berlin office". A note can belong to the whole agent or to one of your end users. The agent can save and look up notes itself, or you can have every turn start with the relevant notes already in context.
Memory is for facts that change over time. A session's messages cover one conversation, and skills hold reusable instructions.
Remember a user's preference
This turns on automatic memory, saves a note for one user, and then asks a fresh question as that user. Set AGENT_ID to one of your ag_... agents.
import { BlazingAgents } from "@blazingagents/sdk";
const client = new BlazingAgents({
apiKey: process.env.BLAZING_AGENTS_API_KEY!,
});
const agentId = process.env.AGENT_ID!;
const userId = "app-user-42";
await client.agents.update({ agentId, memoryInjectionEnabled: true });
await client.memories.create({
agentId,
userId,
text: "Prefers concise status updates.",
});
const result = await client.completion({
agentId,
userId,
prompt: "How should you format my status updates?",
});
console.log(await result.text);The answer mentions keeping updates concise, even though the question never said so. The same note reaches every later turn, in any session, that passes userId: "app-user-42".
Who sees which notes
Each note belongs to one agent. A note saved with userId: "" is general and every turn of that agent sees it. A note saved with a user ID is visible only to turns that pass the same userId. A turn with no userId sees only general notes.
A userId sorts notes. It is not a security boundary: your API key can read and change every note in your account, so your backend decides which user is which. See tenancy and attribution.
Choose how the agent recalls notes
- Automatic. With
memoryInjectionEnabled, each turn starts with the newest visible notes, up to 4,000 words. The last note that fits may be cut short. - Tools. The
memorytool group lets the agent save, look up, search, update, and delete notes on its own during a turn. Add it withtoolson the agent.
Use either one or both. Automatic recall suits a handful of stable preferences. Tools suit an agent that should decide what is worth remembering.
Search and clean up
List a user's notes, optionally filtered by words they contain:
const { data } = await client.memories.list({
agentId,
userId,
search: "status updates",
limit: 10,
});
for (const memory of data) console.log(memory.id, memory.text);Search matches words, not meaning, so "status updates" finds notes containing those words but not "progress reports".
Each agent holds up to 500 notes across all its users. Saving a note at that limit removes the one used least recently. Notes never expire on their own, so delete stale or sensitive notes yourself. Deleting the agent deletes its notes.
Next
- Tenancy and attribution to pass the right
userIdfor each end user. - Built-in tools for what the
memorytools can do. - Memories SDK reference for TypeScript or Python.