InMemoryRecordStorage

open class InMemoryRecordStorage(defaultNamespace: String = "default") : RetrievalStorage, IngestionStorage(source)

In-memory implementation of ai.koog.agents.longtermmemory.retrieval.RetrievalStorage and ai.koog.agents.longtermmemory.ingestion.IngestionStorage that stores records in a map.

This implementation is useful for testing, development, and scenarios where persistence is not required. All data is stored in memory and will be lost when the application stops.

Limitations:

  • Data is not persisted and will be lost on application restart

  • Supports only keyword search using simple substring matching

  • Filter expressions are not supported

Parameters

defaultNamespace

The default namespace to use when none is specified in method calls. Defaults to "default".

Constructors

Link copied to clipboard
constructor(defaultNamespace: String = "default")

Functions

Link copied to clipboard
open suspend override fun add(records: List<MemoryRecord>, namespace: String?)

Adds memory records to the store. If a record with the same ID exists, behavior depends on implementation (insert or upsert).

Link copied to clipboard
open suspend override fun search(request: SearchRequest, namespace: String?): List<SearchResult>

Performs a search and returns results with similarity scores.

Link copied to clipboard
suspend fun size(namespace: String? = null): Int

Returns the number of records in the repository for the specified namespace.