withLongTermMemory
suspend fun <T> AIAgentContext.withLongTermMemory(action: suspend LongTermMemory.() -> T): T(source)
Executes the given action in the context of the LongTermMemory feature installed on this agent.
This is the primary way to access long-term memory storages from within strategy nodes. Inside the action block, you can use LongTermMemory.retrievalSettings and LongTermMemory.ingestionSettings to search and add memory records.
Example usage:
val myNode by node<String, Unit> {
withLongTermMemory {
this.getIngestionStorage()?.add(records, namespace)
val results = this.getRetrievalStorage()?.search(request, namespace)
}
}Content copied to clipboard
Return
the result of the action block.
Parameters
action
the block to execute with LongTermMemory as the receiver.
See also
Throws
if the LongTermMemory feature is not installed.