Agent Skills
› TanStack/ai
› tanstack-ai-memory-in-memory
tanstack-ai-memory-in-memory
GitHub提供TanStack AI内存适配器配置指南,适用于本地开发、测试及单进程演示。说明setup流程、参数选项(如embedder、extract)及使用限制,明确不适用于多进程或需持久化的生产环境。
触发场景
需要为AI应用配置临时内存存储
进行本地开发或单元测试时的记忆功能设置
询问为何不使用持久化存储
安装
npx skills add TanStack/ai --skill tanstack-ai-memory-in-memory -g -y
SKILL.md
Frontmatter
{
"name": "tanstack-ai-memory-in-memory",
"description": "Use when wiring inMemory() from @tanstack\/ai-memory\/in-memory — explains setup, options (embedder, extract, topK\/minScore), when to pick it (dev\/tests\/single-process demos), and what NOT to use it for (multi-process or persistent)."
}
In-Memory Memory Adapter
Zero-dependency recall/save adapter backed by a Map. Records vanish on process
restart.
When to use it
- Local development.
- Vitest / Playwright tests.
- Single-process demos where users don't need persistence.
When NOT to use it
- Production multi-process deployments — every worker has its own
Map; users get inconsistent memory. - Anything that needs survival across restarts.
For production, use redis() (see the tanstack-ai-memory-redis skill).
Setup
import { memoryMiddleware } from '@tanstack/ai-memory'
import { inMemory } from '@tanstack/ai-memory/in-memory'
const memory = inMemory()
memoryMiddleware({ adapter: memory, scope })
Options
inMemory(options?) accepts:
topK(default 6),minScore(default 0.15),kinds— recall tuning.embedder: { embed(text): Promise<number[]> }— enable semantic scoring (bothrecallandsaveembed through it).extract(turn, scope)— return derived facts to persist alongside the raw turn (e.g. call an LLM to pull out preferences). Without it,savestores the raw user/assistant messages andrecallscores them lexically + by recency.render(hits)— replace the built-in prompt renderer.
Capacity
The adapter scans every record in a scope per recall. Fine up to ~100k records; beyond
that, switch to Redis.
版本历史
- 05280a5 当前 2026-07-30 23:52


