LLMSlim + Vercel AI SDK
Long-term memory for AI SDK agents as tools, with no LLM writing your memory and nothing injected into the prompt.
The llmslim npm package is a client for an llmslim serve server. Its llmslim/ai-sdk entry gives the model recall_memory and remember tools, and a middleware that saves each user message and reply. Messages are stored word for word and selected at read time within a token budget, so nothing is summarized or extracted into a wrong fact. Recalled memory reaches the model as a tool result, which your app keeps in its history like any other message.
1. Installation and setup
The client talks to an llmslim serve server (Python, one process, one SQLite file or Postgres). Call it from your backend: an API key gives access to every user's memory.
npm install llmslim ai # ai 7; the client alone has no dependenciesStart the memory server:
pip install "llmslim[server]"
llmslim serve # http://127.0.0.1:8080; set LLMSLIM_API_KEYS to serve beyond localhost2. Architecture & execution flow
3. Production code pattern
import { generateText, stepCountIs, wrapLanguageModel } from "ai";
import { anthropic } from "@ai-sdk/anthropic";
import { LLMSlim } from "llmslim";
import { memoryMiddleware, memoryTools } from "llmslim/ai-sdk";
const client = new LLMSlim(); // LLMSLIM_BASE_URL and LLMSLIM_API_KEY, or pass baseUrl and apiKey
const model = wrapLanguageModel({
model: anthropic("claude-haiku-5-5"),
middleware: memoryMiddleware({ client, userId: session.userId }), // saves each user message and reply
});
const result = await generateText({
model,
tools: memoryTools({ client, userId: session.userId }), // recall_memory and remember
stopWhen: stepCountIs(5),
messages,
});4. Options
Keyword arguments, shown as name = default.