Install any skill in seconds. Free to start, no credit card required.
Get Started Free →Wires memoryMiddleware from @tanstack/ai-memory into chat() calls; covers recall/save adapters, scope security, lifecycle, adapter choices.
29% 96%+67 ptsof test cases passed
Passed 23 of 24 test cases with the skill, and 7 of 24 without it.
This test ran on v3. v4 is the current version and hasn’t been tested on gemini-3.6-flash yet.
3 of 3 safety checks passed
Not used yet
Use this when adding server-side memory to a chat() call. Everything lives in
@tanstack/ai-memory. A memory adapter is a single contract with two verbs — recall
and save — and the middleware is thin: it recalls into the system prompt before the
model runs and defers save after the turn finishes.
Do NOT use this just to keep recent messages — that's the messages array on chat().
Memory is for cross-turn / cross-session recall, not within-turn history.
import { chat, toServerSentEventsResponse } from '@tanstack/ai'
import { openaiText } from '@tanstack/ai-openai'
import { memoryMiddleware } from '@tanstack/ai-memory'
import { inMemory } from '@tanstack/ai-memory/in-memory'
import { requireSession } from './auth'
const memory = inMemory() // dev/tests only — see the in-memory skill
export async function POST(request: Request) {
const { messages } = await request.json()
// Resolved by your auth layer from cookies/headers — never from the request body.
const session = await requireSession(request)
const stream = chat({
adapter: openaiText('gpt-5.5'),
messages,
threadId: session.threadId,
context: { session },
middleware: [
memoryMiddleware({
adapter: memory,
Skills that do similar work, with their benchmark result.
Next to this one in the catalogue, plus more from the same author.