TransactionalMemoryStore
A MemoryStore that applies a write and records it under a key in one transaction, so that a write run again after a crash is not applied twice (the Transactional replay class of the agent runtime, design §4.24 and §4.31).
Every method is one transaction, fenced by token: the store keeps, for each key scope, the newest token any operation on that scope has carried. An operation with an older token is refused with a Left and changes nothing; otherwise its token becomes the scope's newest and it goes ahead. So a writer that has lost its claim can neither apply, nor read back, nor forget anything once its successor has touched the store.
Applied keys are removed only by forgetApplied; clear() keeps them, and the fencing tokens.
Each method returns the store to use next: InMemoryStore is immutable, so its applied keys and tokens are part of its value. The SQL stores return themselves.
Attributes
- Graph
-
- Supertypes
- Known subtypes
Members list
Value members
Abstract methods
The outcome recorded for key, if it was applied; fenced like every operation.
The outcome recorded for key, if it was applied; fenced like every operation.
Attributes
How many applied keys the store holds.
How many applied keys the store holds.
Attributes
In one transaction: for a key already applied, its recorded outcome, writing nothing - even if the memories it stored have since been deleted. Otherwise stores add, deletes remove, then evicts beyond bounds (MemoryBounds.overflow, over the whole store), and records (key, outcome).
In one transaction: for a key already applied, its recorded outcome, writing nothing - even if the memories it stored have since been deleted. Otherwise stores add, deletes remove, then evicts beyond bounds (MemoryBounds.overflow, over the whole store), and records (key, outcome).
remove names what add replaces, as a consolidation's summary replaces its sources: if any memory of remove is no longer there, another writer replaced it first, so nothing is written and the outcome records that nothing was added or removed. Two writers that replace the same memories therefore never both store a replacement.
Attributes
Removes key's record; fenced like every operation. A key that is not there is Right.
Removes key's record; fenced like every operation. A key that is not there is Right.
Attributes
Inherited methods
Check if a memory exists.
Check if a memory exists.
Value parameters
- id
-
The memory identifier
Attributes
- Returns
-
True if memory exists
- Inherited from:
- MemoryStore
Get conversation history.
Get conversation history.
Value parameters
- conversationId
-
The conversation identifier
- limit
-
Maximum messages to return
Attributes
- Returns
-
Conversation memories in chronological order
- Inherited from:
- MemoryStore
Get all memories for a specific entity.
Get all memories for a specific entity.
Value parameters
- entityId
-
The entity identifier
Attributes
- Returns
-
All memories related to this entity
- Inherited from:
- MemoryStore
Get high-importance memories.
Get high-importance memories.
Value parameters
- limit
-
Maximum number of memories
- threshold
-
Minimum importance score (0.0 to 1.0)
Attributes
- Returns
-
Important memories
- Inherited from:
- MemoryStore
Store add, then delete remove: one replacement, such as a consolidation's summary for the memories it summarises. A memory of remove that is not there is skipped.
Store add, then delete remove: one replacement, such as a consolidation's summary for the memories it summarises. A memory of remove that is not there is skipped.
This default stores, then deletes one by one, so it is atomic for a store whose writes return a new store and leave the original untouched (as InMemoryStore does). SQLiteMemoryStore and the Postgres store override it as one transaction; any other store that writes in place should too.
Attributes
- Returns
-
the store after the replacement, or an error
- Inherited from:
- MemoryStore
Store multiple memories in a batch, all or nothing: on Left, none of memories has been stored (a memory that was already there is left as it was). A memory whose id appears twice is stored as its last occurrence.
Store multiple memories in a batch, all or nothing: on Left, none of memories has been stored (a memory that was already there is left as it was). A memory whose id appears twice is stored as its last occurrence.
This default stores into an immutable copy, so it is atomic for a store whose store returns a new store and leaves the original untouched (as InMemoryStore does). A store that writes in place must override it; the SQLite, vector and Postgres stores write the batch in one transaction.
Value parameters
- memories
-
The memories to store
Attributes
- Returns
-
A new MemoryStore containing the added memories, or an error describing why the operation failed.
- Inherited from:
- MemoryStore
Inherited and Abstract methods
Clear all memories from the store.
Clear all memories from the store.
Attributes
- Returns
-
Empty store or error
- Inherited from:
- MemoryStore
Count memories matching a filter.
Count memories matching a filter.
Value parameters
- filter
-
Criteria for counting memories
Attributes
- Returns
-
Count or error
- Inherited from:
- MemoryStore
Delete a memory by its ID.
Delete a memory by its ID.
Value parameters
- id
-
The memory identifier
Attributes
- Returns
-
Updated store or error
- Inherited from:
- MemoryStore
Delete all memories matching a filter.
Delete all memories matching a filter.
Value parameters
- filter
-
Criteria for selecting memories to delete
Attributes
- Returns
-
Updated store or error
- Inherited from:
- MemoryStore
Retrieve a memory by its ID.
Retrieve a memory by its ID.
Value parameters
- id
-
The memory identifier
Attributes
- Returns
-
The memory if found, or error
- Inherited from:
- MemoryStore
Recall memories matching a filter.
Recall memories matching a filter.
This is the primary retrieval method for most use cases. Returns memories sorted by relevance (most relevant first).
Value parameters
- filter
-
Criteria for filtering memories
- limit
-
Maximum number of memories to return
Attributes
- Returns
-
Matching memories sorted by relevance (most relevant first), or error
- Inherited from:
- MemoryStore
Get the most recent memories.
Get the most recent memories.
Value parameters
- filter
-
Additional filter criteria
- limit
-
Maximum number of memories
Attributes
- Returns
-
Most recent memories
- Inherited from:
- MemoryStore
Semantic search for memories similar to a query.
Semantic search for memories similar to a query.
This method uses embeddings for semantic similarity search. Falls back to keyword search if embeddings are not available.
Value parameters
- filter
-
Additional filter criteria
- query
-
The search query
- topK
-
Number of results to return
Attributes
- Returns
-
A list of ScoredMemory objects, sorted by relevance score (highest first), or error
- Inherited from:
- MemoryStore
Store a new memory.
Store a new memory.
Value parameters
- memory
-
The memory to store
Attributes
- Returns
-
Updated store or error
- Inherited from:
- MemoryStore
Update a memory.
Update a memory.
Value parameters
- id
-
The memory identifier
- update
-
Function to transform the memory
Attributes
- Returns
-
Updated store or error
- Inherited from:
- MemoryStore