@supermemory/tools on npm
Check out the NPM page for more details
Installation
Quick comparison
User profiles with middleware
Load the user profile once and reuse the same snapshot throughout the conversation.Prompt caching
Reuse the same wrapped model for every turn of a conversation. Inprofile and
full modes, the profile is fetched on the first user turn and stays unchanged in
the system prompt for the rest of the conversation. query and full modes attach
each turn’s search results to that turn’s user message, and earlier turns keep their
original results, so the prompt prefix stays the same as new messages are appended.
Tool steps reuse their turn’s memories without new requests. The profile is never
refetched during a conversation; facts that change mid-conversation reach the model
through each turn’s search results.
If retrieval fails or times out, the call continues without it by default, and the
next user turn retries the profile. State lives in the wrapper, not in a global or
cross-process cache, so create a new wrapper for each new conversation. Keep system
instructions, tools and earlier messages stable too. Provider cache eligibility and
minimum token counts still apply, so cache-hit savings are not guaranteed.
Required fields
Bothnamespace and id are required.
namespace— who the memories belong to. Use a stable identifier per user, workspace, or tenant (e.g."user-123","acme-workspace"). Memory search and writes are scoped to this tag.id— which conversation this turn belongs to. Use it to group messages from the same chat session into a single document (e.g."chat-2026-04-25", a thread ID, or a UUID per session).
Memory saving is enabled by default (
addMemory: "always"). New conversations are persisted automatically. To opt out, set addMemory: "never":Memory search modes
Profile Mode (Default) - Retrieves the user’s complete profile:Custom prompt templates
Customize how memories are formatted. The template receivesuserMemories, generalSearchMemories, and searchResults (raw array for filtering by metadata):
Verbose logging
When Supermemory errors (default: continue without memories)
If the Supermemory API returns an error, is unreachable, or retrieval hits the internal time limit, memory injection is skipped.skipMemoryOnError defaults to true, so the LLM call still runs with the original prompt (no injected memories). Use verbose: true if you want console output when that happens.
To fail the call when memory retrieval fails instead, set skipMemoryOnError: false:
Persisting tool calls (default: off)
By default, saved conversations include only user and assistant text — tool calls and tool results are dropped, since tool payloads are often large and low-signal and would pollute memory extraction. To persist the full tool round trip (tool calls with their arguments, plus tool results, in their original order), setincludeToolCalls: true:
Memory tools
Add memory capabilities to AI agents.supermemoryTools returns seven tools: searchMemories, addMemory, getProfile, documentList, documentAdd, documentDelete, and memoryForget.