@agentskit/memory
v0.11.8
Published
Persistent and vector memory backends for AgentsKit.
Maintainers
Readme
@agentskit/memory
Profile: major-package
Persist conversations and add vector search to your agents — swap backends without changing agent code.
Tags: ai · agents · llm · agentskit · ai-agents · memory · vector-db · embeddings · rag · sqlite · redis · vector-search
Verified proof
- Package metadata and tests live under
packages/memory/. - Package guide: https://www.agentskit.io/docs/reference/packages/memory
- Stability map: docs/STABILITY.md
How this fits the ecosystem
@agentskit/memory gives agents continuity: chat history, vector memory, graph memory, encrypted stores, and local or hosted backends.
- AgentsKit: compose it with the other packages in this repo to build agents from small, swappable parts.
- Registry: look for ready agents and templates that already use this layer at registry.agentskit.io.
- Playbook: learn the production patterns behind this layer at playbook.agentskit.io.
- AKOS: run the same concepts with enterprise deployment, governance, and observability at akos.agentskit.io.
Docs: package guide · agent handoff
Why memory
- Conversations that survive restarts — SQLite for local development, Redis for production; your agent remembers context across sessions with zero code changes
- RAG-ready vector search — store and retrieve embeddings with
fileVectorMemory(pure JS, no native deps) or Redis vector search for scale - Plug any backend — the
VectorStoreinterface is 3 methods; bring LanceDB, Pinecone, or any custom store in minutes - One interface, every deployment target — swap from
inMemorytosqlitetorediswithout touching agent code
Install
npm install @agentskit/memory better-sqlite3
# For production: npm install redis
# For vectors: npm install vectraQuick example
import { createRuntime } from '@agentskit/runtime'
import { anthropic } from '@agentskit/adapters'
import { sqliteChatMemory } from '@agentskit/memory'
const runtime = createRuntime({
adapter: anthropic({ apiKey: process.env.ANTHROPIC_API_KEY, model: 'claude-sonnet-4-6' }),
memory: sqliteChatMemory({ path: './chat.db' }),
})
// Agent now remembers previous conversations across process restarts
const result = await runtime.run('What did we discuss yesterday?')
console.log(result.content)With RAG
Use a vector backend with @agentskit/rag createRAG({ embed, store }) — fileVectorMemory and redisVectorMemory implement VectorMemory for chunk storage and search.
Features
Chat memory (3)
fileChatMemory({ path })— JSON on disk; zero infra.sqliteChatMemory({ path })— WAL-mode SQLite; indexed by session.redisChatMemory({ client, keyPrefix })— distributed, serverless-friendly.
All on top of createInMemoryMemory / createLocalStorageMemory from
@agentskit/core.
Browser Web Storage
Use the browser-safe subpath when a host needs validated, bounded storage or
sessionStorage instead of the legacy Core localStorage helper:
import { createWebStorageMemory } from '@agentskit/memory/web-storage'
const memory = createWebStorageMemory({
key: 'app:chat',
getStorage: () => typeof sessionStorage === 'undefined' ? undefined : sessionStorage,
maxMessages: 20,
maxRecordBytes: 1_048_576,
})Canonical records are runtime validated. Oversized saves reject with
AK_MEMORY_SAVE_FAILED before changing storage. migration may supply legacy
keys and a host-owned parser; a legacy key is removed only after canonical
persistence succeeds.
Vector memory (7)
fileVectorMemory— pure-JS, file-persisted (good to ~10k vectors).redisVectorMemory— Redis Stack / Redis 8+ HNSW.pgvector— BYO SQL runner (postgres.js,pg, Drizzle, Prisma, Neon).pinecone— managed; namespaces + metadata filters.qdrant— self-hosted or cloud via HTTP.chroma— Chroma v2 HTTP client with tenant, database, and token support.upstashVector— serverless HTTP.
Same 3-method VectorStore contract — swap without touching agent code.
Higher-order wrappers (6)
createHierarchicalMemory— MemGPT-style tiers: working / recall / archival. Recipe.createVirtualizedMemory— hot window + cold retriever for long sessions. Recipe.createAutoSummarizingMemory(via@agentskit/core/auto-summarize) — fold oldest turns into a running summary. Recipe.createEncryptedMemory— AES-GCM-256 envelope over anyChatMemory; keys never leave the caller. Recipe.createInMemoryGraph— knowledge graph (nodes + edges + BFS). Recipe.createInMemoryPersonalization+renderProfileContext— per-user trait profile. Recipe.
Memory contract v1 (ADR 0003) — substitutable across runtime,
useChat, and every framework binding.
Ecosystem
| Package | Role |
|---------|------|
| @agentskit/core | Memory, VectorMemory types |
| @agentskit/rag | Chunking + retrieval on top of vector memory |
| @agentskit/runtime | memory / retriever options |
| @agentskit/adapters | Embeddings for RAG |
Contributors
License
MIT — see LICENSE.
Docs
Maturity and compatibility
- Stability: beta — see docs/STABILITY.md
- Node.js 20+ and TypeScript strict mode
- Published as
@agentskit/memory
Contributing
See CONTRIBUTING.md and the monorepo LICENSE.
