tanstack-ai-memory-hindsight
GitHub集成 TanStack AI Hindsight 记忆适配器,为模型提供按会话分桶的长期记忆能力。支持通过 recall/retain/reflect 工具让模型自主管理上下文,需配置用户、线程作用域及可选向量客户端依赖。
Trigger Scenarios
Install
npx skills add TanStack/ai --skill tanstack-ai-memory-hindsight -g -y
SKILL.md
Frontmatter
{
"name": "tanstack-ai-memory-hindsight",
"description": "Use when wiring hindsight() from @tanstack\/ai-memory\/hindsight — a hosted memory adapter that buckets memory per conversation and exposes retain\/recall\/reflect tools to the model. Requires the optional @vectorize-io\/hindsight-client peer."
}
Hindsight Memory Adapter
Hosted recall/save adapter backed by Hindsight. Hindsight owns extraction and
ranking server-side, buckets memory into per-conversation "banks"
({tenantId|_}__{user}__{threadId}), and — uniquely — exposes LLM tools through recall so the
model can retain/recall/reflect directly.
Setup
import { memoryMiddleware } from '@tanstack/ai-memory'
import { hindsight } from '@tanstack/ai-memory/hindsight'
// Build per request from the server-validated session — never from req.body.
function memoryFor(session: { userId: string; threadId: string }) {
const memory = hindsight({ user: session.userId }) // baseUrl defaults to HINDSIGHT_URL
return memoryMiddleware({
adapter: memory,
scope: { threadId: session.threadId, userId: session.userId },
})
}
@vectorize-io/hindsight-client is an optional peer dependency, loaded lazily on
first use — install it where you use hindsight().
Options
user— durable user id for the bank key (falls back toscope.userId).baseUrl— Hindsight server URL (defaultHINDSIGHT_URLorhttp://localhost:8888).budget— recall budget:'low' | 'mid' | 'high'(default'mid').onToolRetain/onToolRecall— callbacks fired when the model uses the memory tools.
Scope fields: bank id is {tenantId|_}__{user}__{threadId}. namespace is ignored.
Tools
recall returns hindsight_retain, hindsight_recall, and hindsight_reflect in its
tools plus a toolGuidance block. memoryMiddleware merges them into the run so the
model can manage long-term memory itself.
Version History
-
645757a
Current 2026-09-22 03:42
修复代码示例的类型检查问题,更新文档以匹配实际 API(如模型 ID、配置选项),并修正相关代码块内容。
- 05280a5 2026-07-30 23:52


