Class: MemoryManager
Manage memories in the database.
Implements
Constructors
new MemoryManager()
new MemoryManager(
opts
):MemoryManager
Constructs a new MemoryManager instance.
Parameters
• opts
Options for the manager.
• opts.runtime: IAgentRuntime
The AgentRuntime instance associated with this manager.
• opts.tableName: string
The name of the table this manager will operate on.
Returns
Defined in
packages/core/src/memory.ts:35
Properties
runtime
runtime:
IAgentRuntime
The AgentRuntime instance associated with this manager.
Implementation of
Defined in
packages/core/src/memory.ts:22
tableName
tableName:
string
The name of the database table this manager operates on.
Implementation of
Defined in
packages/core/src/memory.ts:27
Methods
addEmbeddingToMemory()
addEmbeddingToMemory(
memory
):Promise
<Memory
>
Adds an embedding vector to a memory object. If the memory already has an embedding, it is returned as is.
Parameters
• memory: Memory
The memory object to add an embedding to.
Returns
Promise
<Memory
>
A Promise resolving to the memory object, potentially updated with an embedding vector.
Implementation of
IMemoryManager
.addEmbeddingToMemory
Defined in
packages/core/src/memory.ts:45
countMemories()
countMemories(
roomId
,unique
):Promise
<number
>
Counts the number of memories associated with a set of user IDs, with an option for uniqueness.
Parameters
• roomId: `${string}-${string}-${string}-${string}-${string}`
The room ID to count memories for.
• unique: boolean
= true
Whether to count unique memories only.
Returns
Promise
<number
>
A Promise resolving to the count of memories.
Implementation of
Defined in
packages/core/src/memory.ts:219
createMemory()
createMemory(
memory
,unique
):Promise
<void
>
Creates a new memory in the database, with an option to check for similarity before insertion.
Parameters
• memory: Memory
The memory object to create.
• unique: boolean
= false
Whether to check for similarity before insertion.
Returns
Promise
<void
>
A Promise that resolves when the operation completes.
Implementation of
Defined in
packages/core/src/memory.ts:158
getCachedEmbeddings()
getCachedEmbeddings(
content
):Promise
<object
[]>
Parameters
• content: string
Returns
Promise
<object
[]>
Implementation of
IMemoryManager
.getCachedEmbeddings
Defined in
packages/core/src/memory.ts:93
getMemories()
getMemories(
opts
):Promise
<Memory
[]>
Retrieves a list of memories by user IDs, with optional deduplication.
Parameters
• opts
Options including user IDs, count, and uniqueness.
• opts.agentId?: `${string}-${string}-${string}-${string}-${string}`
• opts.count?: number
= 10
The number of memories to retrieve.
• opts.end?: number
• opts.roomId: `${string}-${string}-${string}-${string}-${string}`
The room ID to retrieve memories for.
• opts.start?: number
• opts.unique?: boolean
= true
Whether to retrieve unique memories only.
Returns
Promise
<Memory
[]>
A Promise resolving to an array of Memory objects.
Implementation of
Defined in
packages/core/src/memory.ts:66
getMemoriesByRoomIds()
getMemoriesByRoomIds(
params
):Promise
<Memory
[]>
Parameters
• params
• params.agentId?: `${string}-${string}-${string}-${string}-${string}`
• params.roomIds: `${string}-${string}-${string}-${string}-${string}`[]
Returns
Promise
<Memory
[]>
Implementation of
IMemoryManager
.getMemoriesByRoomIds
Defined in
packages/core/src/memory.ts:173
getMemoryById()
getMemoryById(
id
):Promise
<Memory
>
Parameters
• id: `${string}-${string}-${string}-${string}-${string}`
Returns
Promise
<Memory
>
Implementation of
Defined in
packages/core/src/memory.ts:184
removeAllMemories()
removeAllMemories(
roomId
):Promise
<void
>
Removes all memories associated with a set of user IDs.
Parameters
• roomId: `${string}-${string}-${string}-${string}-${string}`
The room ID to remove memories for.
Returns
Promise
<void
>
A Promise that resolves when the operation completes.
Implementation of
IMemoryManager
.removeAllMemories
Defined in
packages/core/src/memory.ts:206
removeMemory()
removeMemory(
memoryId
):Promise
<void
>
Removes a memory from the database by its ID.
Parameters
• memoryId: `${string}-${string}-${string}-${string}-${string}`
The ID of the memory to remove.
Returns
Promise
<void
>
A Promise that resolves when the operation completes.
Implementation of
Defined in
packages/core/src/memory.ts:194
searchMemoriesByEmbedding()
searchMemoriesByEmbedding(
embedding
,opts
):Promise
<Memory
[]>
Searches for memories similar to a given embedding vector.
Parameters
• embedding: number
[]
The embedding vector to search with.
• opts
Options including match threshold, count, user IDs, and uniqueness.
• opts.agentId?: `${string}-${string}-${string}-${string}-${string}`
• opts.count?: number
The maximum number of memories to retrieve.
• opts.match_threshold?: number
The similarity threshold for matching memories.
• opts.roomId: `${string}-${string}-${string}-${string}-${string}`
The room ID to retrieve memories for.
• opts.unique?: boolean
Whether to retrieve unique memories only.
Returns
Promise
<Memory
[]>
A Promise resolving to an array of Memory objects that match the embedding.
Implementation of
IMemoryManager
.searchMemoriesByEmbedding