Skip to content
AgentsKit

@agentskit/memory β€” Functions

API functions for @agentskit/memory.

#Function: adaptIoredis()

adaptIoredis(io): RedisLike

Defined in: packages/memory/src/kv-store-redis.ts:84

Bridges an ioredis-style client to the RedisLike options-object shape.

#Parameters

#io

Client with positional Redis command options.

#del

(key) => Promise<unknown>

#get

(key) => Promise<string | null>

#keys

(pattern) => Promise<string[]>

#set

(key, value, mode?, ttl?) => Promise<unknown>

#Returns

RedisLike

A client using the memory package's Redis contract.


#Function: chroma()

chroma(config): VectorMemory

Defined in: packages/memory/src/vector/chroma.ts:41

Creates a vector memory backed by Chroma's HTTP API.

#Parameters

#config

ChromaConfig

Chroma URL, collection, credentials, and search defaults.

#Returns

VectorMemory

A vector memory backed by the configured collection.


#Function: createEncryptedMemory()

createEncryptedMemory(options): Promise<ChatMemory>

Defined in: packages/memory/src/encrypted.ts:81

Wraps chat memory with AES-GCM encryption using caller-owned key material.

#Parameters

#options

EncryptedMemoryOptions

Backing memory, key, and optional Web Crypto settings.

#Returns

Promise<ChatMemory>

A chat memory that encrypts saved content and decrypts loaded content.

#Throws

When the key is invalid.

#Throws

When Web Crypto is unavailable.

#Example

const key = crypto.getRandomValues(new Uint8Array(32))
const memory = await createEncryptedMemory({ backing, key })

#Function: createFileStore()

createFileStore(config): AgentskitMemoryStore

Defined in: packages/memory/src/kv-store-basic.ts:86

Creates a JSON file key-value store with atomic file replacement.

#Parameters

#config

FileKvConfig

File path and optional retention settings.

#Returns

AgentskitMemoryStore

A persistent key-value store backed by the configured file.


#Function: createHierarchicalMemory()

createHierarchicalMemory(options): HierarchicalMemory

Defined in: packages/memory/src/hierarchical.ts:76

MemGPT-style tiered memory. Three tiers:

  • working: always-loaded hot window (bounded by workingLimit).
  • recall: mid-term searchable layer (usually a vector store).
  • archival: cold store that always holds the full conversation.

On every save, new messages are appended to archival, messages that overflow the working window are indexed into recall, and the working tier is trimmed to workingLimit.

On every load, the hub returns working + up to recallTopK messages surfaced by the recall tier, spliced chronologically.

#Parameters

#options

HierarchicalMemoryOptions

Working and archival memories plus optional recall settings.

#Returns

HierarchicalMemory

A chat memory that keeps an archival history and bounded working window.


#Function: createInMemoryGraph()

createInMemoryGraph(): GraphMemory

Defined in: packages/memory/src/graph.ts:57

In-memory graph β€” fine for tests, single-process demos, and as reference for what a backing store needs to implement.

#Returns

GraphMemory


#Function: createInMemoryPersonalization()

createInMemoryPersonalization(): PersonalizationStore

Defined in: packages/memory/src/personalization.ts:28

In-memory personalization store β€” tests, single-process demos. Bring your own for production (Postgres, Redis, DynamoDB).

#Returns

PersonalizationStore


#Function: createInMemoryStore()

createInMemoryStore(config): AgentskitMemoryStore

Defined in: packages/memory/src/kv-store-basic.ts:61

Creates an in-memory key-value store with optional TTL and size limits.

#Parameters

#config

InMemoryKvConfig

Backend and retention settings.

#Returns

AgentskitMemoryStore

A key-value store backed by a process-local map.

#Throws

When retention limits are invalid.


#Function: createKvMemoryFromConfig()

createKvMemoryFromConfig(options): AgentskitMemoryStore

Defined in: packages/memory/src/kv-store-factory.ts:73

Creates a KV store for the selected backend using supplied dependencies.

#Parameters

#options

CreateKvMemoryFromConfigOpts

Backend config and optional database, cache, vector, and embedding adapters.

#Returns

AgentskitMemoryStore

A store implementing asynchronous get and set.

#Throws

When a selected external backend lacks a required adapter.

#Example

const store = createKvMemoryFromConfig({ config: { backend: 'in-memory' } })
await store.set('job:42', { status: 'ready' })

#Function: createKvMemoryFromConfigAuto()

createKvMemoryFromConfigAuto(config): Promise<AgentskitMemoryStore>

Defined in: packages/memory/src/kv-store-factory.ts:135

Creates a KV store and lazy-loads the optional SQLite or Redis driver.

#Parameters

#config

KvMemoryConfig

Backend discriminator and settings.

#Returns

Promise<AgentskitMemoryStore>

A store implementing asynchronous get and set.

#Throws

When an optional driver is missing or vector adapters are not injected.


#Function: createLocalStorageStore()

createLocalStorageStore(options): AgentskitMemoryStore

Defined in: packages/memory/src/kv-store-basic.ts:145

Creates a local-storage store, falling back to a JSON file when unavailable.

#Parameters

#options

CreateLocalStorageStoreOpts

Storage configuration and optional storage/file adapters.

#Returns

AgentskitMemoryStore

A key-value store backed by Web Storage or the configured file.

#Throws

When retention limits are invalid.


#Function: createRedisStore()

createRedisStore(options): AgentskitMemoryStore

Defined in: packages/memory/src/kv-store-redis.ts:23

Creates a Redis key-value store using the supplied client.

#Parameters

#options

CreateRedisStoreOpts

Redis configuration and client.

#Returns

AgentskitMemoryStore

A key-value store backed by the configured Redis prefix.

#Throws

When retention limits are invalid.

#Throws

When Redis commands fail.


#Function: createSqliteStore()

createSqliteStore(options): AgentskitMemoryStore

Defined in: packages/memory/src/kv-store-sqlite.ts:22

Creates a SQLite key-value store using the supplied database opener.

#Parameters

#options

CreateSqliteStoreOpts

SQLite configuration and opener.

#Returns

AgentskitMemoryStore

A key-value store backed by the configured database.


#Function: createVectorStore()

createVectorStore(options): AgentskitMemoryStore & object

Defined in: packages/memory/src/kv-store-vector.ts:26

Creates a key-value store that embeds keys and stores values in a vector store.

#Parameters

#options

CreateVectorStoreOpts

Vector config, store, and embedder.

#Returns

AgentskitMemoryStore & object

A key-value store with a similarity-based recall method.

#Throws

When the embedder returns no vector.


#Function: createWebStorageMemory()

createWebStorageMemory(options): ChatMemory

Defined in: packages/memory/src/web-storage.ts:89

Creates a validated, bounded ChatMemory over an injected browser Web Storage backend. The storage getter is evaluated lazily so browser globals can remain SSR-safe.

#Parameters

#options

WebStorageMemoryOptions

Storage key, getter, retention limits, and optional migration.

#Returns

ChatMemory

A chat memory that validates and bounds records in Web Storage.

#Throws

When the key or a configured limit is invalid.

#Throws

When a saved message record is invalid or exceeds its byte limit.

#Example

const memory = createWebStorageMemory({
  key: 'agentskit-chat',
  getStorage: () => globalThis.localStorage,
})

#Function: fileChatMemory()

fileChatMemory(path): ChatMemory

Defined in: packages/memory/src/file-chat.ts:24

ChatMemory backed by a JSON file on disk. Node-only.

Implements the Memory contract (ADR 0003):

  • load() returns a snapshot (CM1)
  • save() is replace-all, not append (CM2)
  • empty state returns [] (CM5)
  • clear() is optional but provided here

#Parameters

#path

string

#Returns

ChatMemory


#Function: fileVectorMemory()

fileVectorMemory(config): VectorMemory

Defined in: packages/memory/src/file-vector.ts:116

Creates a persistent vector memory backed by a local Vectra index.

#Parameters

#config

FileVectorMemoryConfig

Index path and optional vector-store adapter.

#Returns

VectorMemory

A vector memory that stores and searches local embeddings.

#Throws

When the optional vectra dependency is unavailable.

#Example

const memory = fileVectorMemory({ path: './vectors' })
await memory.store([{ id: 'guide', content: 'Guide text', embedding }])

#Function: forgetSubject()

forgetSubject(memories, subjectId): Promise<ForgetSubjectResult>

Defined in: packages/memory/src/forget.ts:85

Walk every memory passed in and run forgetSubject(subjectId) on any that implement it. Missing capabilities are reported so callers cannot mistake a partial deletion for a complete one.

#Parameters

#memories

unknown[]

Memory instances to inspect for deletion capability.

#subjectId

string

Subject identifier to delete.

#Returns

Promise<ForgetSubjectResult>

Per-backend reports and an incomplete flag for skipped or failed backends.


#Function: isMemoryBackendSupported()

isMemoryBackendSupported(backend): boolean

Defined in: packages/memory/src/kv-store-factory.ts:50

Reports whether a key-value backend is currently supported.

#Parameters

#backend

"in-memory" | "file" | "sqlite" | "redis" | "vector" | "localstorage"

Backend discriminator to check.

#Returns

boolean

true when the factory can construct that backend.


#Function: makeForgettable()

makeForgettable<M>(memory, options): M & ForgettableMemory

Defined in: packages/memory/src/forget.ts:125

Helper for backends that key records by metadata.subjectId. Wraps any delete(ids)-style API into a ForgettableMemory.

#Type Parameters

#M

M extends object

#Parameters

#memory

M

Object to extend with the deletion capability.

#options

Backend label and functions for listing and deleting matching ids.

#backend

string

#deleteIds

(ids) => Promise<void>

#listIds

(subjectId) => Promise<string[]>

#Returns

M & ForgettableMemory

The same object with ForgettableMemory methods and metadata.


#Function: matchesFilter()

matchesFilter(metadata, filter): boolean

Defined in: packages/memory/src/vector/filter.ts:37

Evaluate a VectorFilter against a metadata record. Used by in-memory / file-backed vector stores. Backends with native filter languages (pgvector, Pinecone, Qdrant, etc.) translate the filter to their own form instead.

#Parameters

#metadata

Record<string, unknown> | undefined

#filter

VectorFilter | undefined

#Returns

boolean


#Function: milvusVectorStore()

milvusVectorStore(config): VectorMemory

Defined in: packages/memory/src/vector/milvus.ts:36

Creates a vector memory backed by the Milvus HTTP API.

#Parameters

#config

MilvusConfig

Endpoint, collection, credentials, and search defaults.

#Returns

VectorMemory

A vector memory backed by the configured collection.


#Function: mongoAtlasVectorStore()

mongoAtlasVectorStore(config): VectorMemory

Defined in: packages/memory/src/vector/mongo-atlas.ts:37

Creates a vector memory backed by a MongoDB Atlas collection.

#Parameters

#config

MongoAtlasVectorConfig

Collection adapter, vector field, and search settings.

#Returns

VectorMemory

A vector memory backed by the configured collection.


#Function: pgvector()

pgvector(config): VectorMemory

Defined in: packages/memory/src/vector/pgvector.ts:37

Creates a vector memory backed by a PostgreSQL pgvector table.

#Parameters

#config

PgVectorConfig

SQL runner and optional table and result limit.

#Returns

VectorMemory

A vector memory that upserts and searches the configured table.


#Function: pinecone()

pinecone(config): VectorMemory

Defined in: packages/memory/src/vector/pinecone.ts:30

Creates a vector memory backed by the Pinecone vector API.

#Parameters

#config

PineconeConfig

Index endpoint, API key, and optional namespace and result limit.

#Returns

VectorMemory

A vector memory backed by the configured Pinecone index.


#Function: qdrant()

qdrant(config): VectorMemory

Defined in: packages/memory/src/vector/qdrant.ts:54

Creates a vector memory backed by a Qdrant collection.

#Parameters

#config

QdrantConfig

Qdrant endpoint, collection, and optional credentials and result limit.

#Returns

VectorMemory

A vector memory backed by the configured collection.


#Function: redisChatMemory()

redisChatMemory(config): ChatMemory

Defined in: packages/memory/src/redis-chat.ts:32

Creates a chat memory that stores conversation snapshots in Redis.

#Parameters

#config

RedisChatMemoryConfig

Redis URL or client and optional namespace settings.

#Returns

ChatMemory

A chat memory backed by Redis.

#Throws

When the optional Redis dependency is missing or cannot connect.


#Function: redisVectorMemory()

redisVectorMemory(config): VectorMemory

Defined in: packages/memory/src/redis-vector.ts:25

Creates a vector memory backed by Redis vector search commands.

#Parameters

#config

RedisVectorMemoryConfig

Redis URL or client and optional index settings.

#Returns

VectorMemory

A vector memory backed by the configured Redis index.

#Throws

When the optional Redis dependency is missing or cannot connect.


#Function: renderProfileContext()

renderProfileContext(profile): string

Defined in: packages/memory/src/personalization.ts:64

Render a profile into a system-prompt fragment the runtime can prepend. Kept intentionally short β€” full profile dumps bloat context and leak unnecessary detail to the model.

#Parameters

#profile

PersonalizationProfile | null

#Returns

string


#Function: sqliteChatMemory()

sqliteChatMemory(config): ChatMemory

Defined in: packages/memory/src/sqlite.ts:56

Creates a chat memory that stores conversation snapshots in SQLite.

#Parameters

#config

SqliteChatMemoryConfig

Database path and optional opener.

#Returns

ChatMemory

A chat memory backed by the configured database.

#Throws

When the optional SQLite dependency is missing or cannot open the database.


#Function: supabaseVectorStore()

supabaseVectorStore(config): VectorMemory

Defined in: packages/memory/src/vector/supabase.ts:84

Creates a vector memory backed by a Supabase table and RPC search function.

#Parameters

#config

SupabaseVectorStoreConfig

Supabase client, table, and optional search settings.

#Returns

VectorMemory

A vector memory backed by the configured Supabase schema.


#Function: tryDefaultRedisClient()

tryDefaultRedisClient(url): Promise<RedisLike | undefined>

Defined in: packages/memory/src/kv-store-redis.ts:102

Loads and connects node-redis, returning undefined when it is unavailable.

#Parameters

#url

string

Redis connection URL.

#Returns

Promise<RedisLike | undefined>

A connected client, or undefined when the optional package is absent.

#Throws

When the client cannot connect.


#Function: tryDefaultSqliteOpener()

tryDefaultSqliteOpener(): Promise<SqliteOpener | undefined>

Defined in: packages/memory/src/kv-store-sqlite.ts:84

Lazy-import better-sqlite3 and return an opener, or undefined when the optional peer dep is absent (caller surfaces AK_MEMORY_PEER_MISSING).

#Returns

Promise<SqliteOpener | undefined>

An opener, or undefined when better-sqlite3 is unavailable.


#Function: tursoChatMemory()

tursoChatMemory(config): ChatMemory

Defined in: packages/memory/src/turso.ts:70

libSQL / Turso-backed chat memory. Mirrors the sqliteChatMemory shape so code paths can swap between local SQLite and replicated libSQL by changing one import.

@libsql/client is an optional peer dependency loaded lazily.

#Parameters

#config

TursoChatMemoryConfig

#Returns

ChatMemory


#Function: upstashVector()

upstashVector(config): VectorMemory

Defined in: packages/memory/src/vector/upstash.ts:30

Upstash Vector β€” HTTP-only serverless vector DB. The REST surface is tiny enough to implement directly without pulling the SDK.

#Parameters

#config

UpstashVectorConfig

#Returns

VectorMemory


#Function: weaviateVectorStore()

weaviateVectorStore(config): VectorMemory

Defined in: packages/memory/src/vector/weaviate.ts:36

Creates a vector memory backed by a Weaviate class.

#Parameters

#config

WeaviateConfig

Weaviate endpoint, class, and optional credentials and result limit.

#Returns

VectorMemory

A vector memory backed by the configured class.


#Function: wrapChatMemoryWithRedaction()

wrapChatMemoryWithRedaction(inner, options): ChatMemory

Defined in: packages/memory/src/redaction.ts:89

Wraps chat memory to redact or tokenize message content before saves.

#Parameters

#inner

ChatMemory

Chat memory implementation to wrap.

#options

ChatMemoryRedactionOptions

Redaction rules and optional tokenization settings.

#Returns

ChatMemory

A chat memory wrapper that redacts saved message content.

#Throws

When tokenization lacks a vault or allowed roles.


#Function: wrapVectorMemoryWithRedaction()

wrapVectorMemoryWithRedaction(inner, options): VectorMemory

Defined in: packages/memory/src/redaction.ts:126

Wrap any VectorMemory so each document's content is redacted (or tokenized) before store(). search() and delete() pass through.

Note: embeddings pass through verbatim. Customers who embed plaintext PII separately (e.g. via a hosted embedding provider) must redact the input to their embedder, not just to this wrapper.

#Parameters

#inner

VectorMemory

#options

VectorMemoryRedactionOptions

#Returns

VectorMemory

Explore nearby

On this page

Function: adaptIoredis()ParametersiodelgetkeyssetReturnsFunction: chroma()ParametersconfigReturnsFunction: createEncryptedMemory()ParametersoptionsReturnsThrowsThrowsExampleFunction: createFileStore()ParametersconfigReturnsFunction: createHierarchicalMemory()ParametersoptionsReturnsFunction: createInMemoryGraph()ReturnsFunction: createInMemoryPersonalization()ReturnsFunction: createInMemoryStore()ParametersconfigReturnsThrowsFunction: createKvMemoryFromConfig()ParametersoptionsReturnsThrowsExampleFunction: createKvMemoryFromConfigAuto()ParametersconfigReturnsThrowsFunction: createLocalStorageStore()ParametersoptionsReturnsThrowsFunction: createRedisStore()ParametersoptionsReturnsThrowsThrowsFunction: createSqliteStore()ParametersoptionsReturnsFunction: createVectorStore()ParametersoptionsReturnsThrowsFunction: createWebStorageMemory()ParametersoptionsReturnsThrowsThrowsExampleFunction: fileChatMemory()ParameterspathReturnsFunction: fileVectorMemory()ParametersconfigReturnsThrowsExampleFunction: forgetSubject()ParametersmemoriessubjectIdReturnsFunction: isMemoryBackendSupported()ParametersbackendReturnsFunction: makeForgettable()Type ParametersMParametersmemoryoptionsbackenddeleteIdslistIdsReturnsFunction: matchesFilter()ParametersmetadatafilterReturnsFunction: milvusVectorStore()ParametersconfigReturnsFunction: mongoAtlasVectorStore()ParametersconfigReturnsFunction: pgvector()ParametersconfigReturnsFunction: pinecone()ParametersconfigReturnsFunction: qdrant()ParametersconfigReturnsFunction: redisChatMemory()ParametersconfigReturnsThrowsFunction: redisVectorMemory()ParametersconfigReturnsThrowsFunction: renderProfileContext()ParametersprofileReturnsFunction: sqliteChatMemory()ParametersconfigReturnsThrowsFunction: supabaseVectorStore()ParametersconfigReturnsFunction: tryDefaultRedisClient()ParametersurlReturnsThrowsFunction: tryDefaultSqliteOpener()ReturnsFunction: tursoChatMemory()ParametersconfigReturnsFunction: upstashVector()ParametersconfigReturnsFunction: weaviateVectorStore()ParametersconfigReturnsFunction: wrapChatMemoryWithRedaction()ParametersinneroptionsReturnsThrowsFunction: wrapVectorMemoryWithRedaction()ParametersinneroptionsReturns