tanstack-ai-memory-in-memory

Configures the inMemory() adapter for Map-backed recall and save in TanStack AI memory middleware.

3.1k|316|Updated Oct 8, 2025
One-click install
npx skills add https://github.com/TanStack/ai --skill tanstack-ai-memory-in-memory
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: tanstack-ai-memory-in-memory
Source: https://github.com/TanStack/ai/tree/main/packages/ai-memory/skills/tanstack-ai-memory-in-memory
Command: npx skills add https://github.com/TanStack/ai --skill tanstack-ai-memory-in-memory

SYSTEM DOCUMENTATION & REQUIREMENTS

💡 This Skill requires @tanstack/ai-memory.

What problem does it solve?

Developers need a zero-dependency memory adapter for TanStack AI that works in local development, tests, and single-process demos without standing up external infrastructure like Redis.

Core Features & Use Cases

  • Zero-Dependency Adapter: Provides recall/save backed by a plain Map, requiring no external services.
  • Tunable Recall: Supports topK, minScore, and kinds options, plus an optional embedder for semantic scoring.
  • Custom Extraction and Rendering: Accepts an extract function to persist derived facts and a render function to replace the built-in prompt renderer.
  • Use Case: In a Vitest suite, wire inMemory() into memoryMiddleware so each test run gets isolated conversational memory without provisioning Redis.

Quick Start

Set up the inMemory adapter from @tanstack/ai-memory/in-memory and pass it to memoryMiddleware for my local development chat agent.

Frequently Asked Questions about tanstack-ai-memory-in-memory

High-intent search queries and answers about installing and using this skill.

FAQPage Schema
How do I set up in-memory memory for TanStack AI?

Import inMemory from @tanstack/ai-memory/in-memory and pass the result to memoryMiddleware as the adapter along with a scope. No external services or configuration are required for basic usage.

When should I use inMemory vs Redis for TanStack AI memory?

Use inMemory for local development, tests, and single-process demos where persistence is not needed. Use the redis() adapter for production multi-process deployments or anything that must survive restarts, since each process keeps its own Map.

Does the inMemory adapter support semantic search?

Yes, pass an embedder option with an embed(text) function returning a number array. Both recall and save then embed through it for semantic scoring; without it, recall scores lexically and by recency.

What are the limitations of the inMemory memory adapter?

Records vanish on process restart and each worker process has its own Map, so multi-process deployments get inconsistent memory. It scans every record per recall, which is fine up to roughly 100k records before Redis is recommended.

How do I store derived facts instead of raw messages with inMemory?

Pass an extract(turn, scope) option that returns derived facts to persist alongside the raw turn, such as calling an LLM to pull out user preferences. Without it, save stores the raw user and assistant messages.