LLMMemoryManager

org.llm4s.agent.memory.LLMMemoryManager
See theLLMMemoryManager companion object
final case class LLMMemoryManager(config: MemoryManagerConfig, store: MemoryStore, client: LLMClient) extends MemoryManager

Memory manager with LLM-powered consolidation and entity extraction.

Extends basic memory management with advanced features:

  • Automatic memory consolidation using LLM summarization
  • Entity extraction from conversation text (TODO: Phase 2)
  • Importance scoring based on content analysis (TODO: Phase 2)

This implementation follows the same patterns as SimpleMemoryManager but adds LLM-powered intelligence for memory operations.

Value parameters

client

LLM client for consolidation and extraction

config

Configuration for memory management

store

Underlying memory store

Attributes

Companion
object
Graph
Supertypes
trait Serializable
trait Product
trait Equals
class Object
trait Matchable
class Any
Show all

Members list

Value members

Concrete methods

override def consolidateMemories(olderThan: Instant, minCount: Int): Result[MemoryManager]

Summarize and consolidate old memories.

Summarize and consolidate old memories.

This operation can reduce memory usage by combining related memories into summaries.

Value parameters

minCount

Minimum memories to trigger consolidation

olderThan

Only consolidate memories older than this

Attributes

Returns

Updated manager or error

Definition Classes
override def extractEntities(text: String, conversationId: Option[String]): Result[MemoryManager]

Extract and store entity mentions from text.

Extract and store entity mentions from text.

Uses NLP or LLM to identify entities in the text and create entity memories.

Value parameters

conversationId

Optional conversation context

text

Text to analyze

Attributes

Returns

Updated manager with extracted entities

Definition Classes
override def getConversationContext(conversationId: String, maxMessages: Int): Result[String]

Get recent conversation context.

Get recent conversation context.

Value parameters

conversationId

The conversation to retrieve

maxMessages

Maximum messages to include

Attributes

Returns

Formatted conversation history

Definition Classes
override def getEntityContext(entityId: EntityId): Result[String]

Get all known facts about an entity.

Get all known facts about an entity.

Value parameters

entityId

The entity to query

Attributes

Returns

Formatted entity knowledge

Definition Classes
override def getRelevantContext(query: String, maxTokens: Int, filter: MemoryFilter): Result[String]

Retrieve relevant context for a query.

Retrieve relevant context for a query.

This is the main method for memory-augmented generation. Returns memories most relevant to the given query, formatted as context for the LLM.

Value parameters

filter

Additional filter criteria

maxTokens

Approximate maximum tokens of context

query

The user's query

Attributes

Returns

Formatted context string

Definition Classes
override def getUserContext(userId: Option[String]): Result[String]

Get facts known about the user.

Get facts known about the user.

Value parameters

userId

Optional user identifier

Attributes

Returns

Formatted user knowledge

Definition Classes
override def recordConversation(messages: Seq[Message], conversationId: String): Result[MemoryManager]

Record a complete conversation.

Record a complete conversation.

Value parameters

conversationId

Identifier for this conversation

messages

The conversation messages

Attributes

Returns

Updated manager or error

Definition Classes
override def recordEntityFact(entityId: EntityId, entityName: String, fact: String, entityType: String, importance: Option[Double]): Result[MemoryManager]

Store a fact about an entity.

Store a fact about an entity.

Value parameters

entityId

The entity this fact is about

entityName

Human-readable entity name

entityType

Type of entity (person, organization, concept, etc.)

fact

The fact to store

importance

Optional importance score

Attributes

Returns

Updated manager or error

Definition Classes
override def recordKnowledge(content: String, source: String, metadata: Map[String, String]): Result[MemoryManager]

Store knowledge from an external source.

Store knowledge from an external source.

Value parameters

content

The knowledge content

metadata

Additional metadata

source

Source identifier (file path, URL, etc.)

Attributes

Returns

Updated manager or error

Definition Classes
override def recordMessage(message: Message, conversationId: String, importance: Option[Double]): Result[MemoryManager]

Record a conversation turn.

Record a conversation turn.

Value parameters

conversationId

Identifier for this conversation

importance

Optional importance score

message

The message to record

Attributes

Returns

Updated manager or error

Definition Classes
override def recordTask(description: String, outcome: String, success: Boolean, importance: Option[Double]): Result[MemoryManager]

Record a completed task and its outcome.

Record a completed task and its outcome.

Value parameters

description

Task description

importance

Optional importance score

outcome

What happened

success

Whether the task succeeded

Attributes

Returns

Updated manager or error

Definition Classes
override def recordUserFact(fact: String, userId: Option[String], importance: Option[Double]): Result[MemoryManager]

Store a fact about the user.

Store a fact about the user.

Value parameters

fact

The fact about the user

importance

Optional importance score

userId

Optional user identifier

Attributes

Returns

Updated manager or error

Definition Classes
override def stats: Result[MemoryStats]

Get memory statistics.

Get memory statistics.

Attributes

Definition Classes

Inherited methods

def productElementNames: Iterator[String]

Attributes

Inherited from:
Product
def productIterator: Iterator[Any]

Attributes

Inherited from:
Product