agents.memory_v2.standalone_rag_memoryΒΆ

Standalone RAG-based Memory Agent using BaseRAGAgent with retrievers.

This module provides memory-capable agents built on BaseRAGAgent without dependencies on the broken memory module. All models are defined here.

Key features: 1. ConversationMemoryAgent - conversation history with time-weighting 2. FactualMemoryAgent - factual information storage and retrieval 3. PreferencesMemoryAgent - user preferences with generation 4. UnifiedMemoryRAGAgent - coordinates all memory types 5. Real BaseRAGAgent integration with different retrievers 6. Vector store persistence across different backends

NO MOCKS - All components use real BaseRAGAgent with real retrievers.

ClassesΒΆ

ConversationMemoryAgent

Memory agent for conversation history using BaseRAGAgent.

FactualMemoryAgent

Memory agent for factual information using BaseRAGAgent.

ImportanceLevel

Importance levels for memories.

MemoryRAGConfig

Configuration for RAG-based memory agents.

MemoryType

Types of memories that can be stored.

MessageDocumentConverter

Convert messages to documents for RAG storage.

PreferencesMemoryAgent

Memory agent for user preferences using SimpleRAGAgent for generation.

StandaloneMemoryItem

Standalone memory item for RAG-based storage.

UnifiedMemoryRAGAgent

Unified memory agent coordinating multiple specialized memory agents.

FunctionsΒΆ

create_conversation_memory_agent([...])

Factory function to create conversation memory agent.

create_unified_memory_agent([user_id, llm_config, ...])

Factory function to create unified memory agent.

demo()

Demo.

Module ContentsΒΆ

class agents.memory_v2.standalone_rag_memory.ConversationMemoryAgent(config, name='conversation_memory')ΒΆ

Memory agent for conversation history using BaseRAGAgent.

Initialize conversation memory agent.

Parameters:
async add_conversation(messages)ΒΆ

Add conversation messages to memory.

Parameters:

messages (list[langchain_core.messages.BaseMessage])

Return type:

None

async initialize()ΒΆ

Initialize the underlying RAG agent.

Return type:

None

async retrieve_conversation_context(query, k=None)ΒΆ

Retrieve relevant conversation context.

Parameters:
Return type:

list[langchain_core.documents.Document]

class agents.memory_v2.standalone_rag_memory.FactualMemoryAgent(config, name='factual_memory')ΒΆ

Memory agent for factual information using BaseRAGAgent.

Initialize factual memory agent.

Parameters:
async add_memories(memories)ΒΆ

Add multiple factual memories.

Parameters:

memories (list[StandaloneMemoryItem])

Return type:

None

async add_memory(memory)ΒΆ

Add a factual memory.

Parameters:

memory (StandaloneMemoryItem)

Return type:

None

async initialize()ΒΆ

Initialize the underlying RAG agent.

Return type:

None

async retrieve_facts(query, k=None)ΒΆ

Retrieve relevant factual memories.

Parameters:
Return type:

list[dict[str, Any]]

class agents.memory_v2.standalone_rag_memory.ImportanceLevelΒΆ

Bases: str, enum.Enum

Importance levels for memories.

Initialize self. See help(type(self)) for accurate signature.

class agents.memory_v2.standalone_rag_memory.MemoryRAGConfig(/, **data)ΒΆ

Bases: pydantic.BaseModel

Configuration for RAG-based memory agents.

Create a new model by parsing and validating input data from keyword arguments.

Raises [ValidationError][pydantic_core.ValidationError] if the input data cannot be validated to form a valid model.

self is explicitly positional-only to allow self as a field name.

Parameters:

data (Any)

model_configΒΆ

Configuration for the model, should be a dictionary conforming to [ConfigDict][pydantic.config.ConfigDict].

class agents.memory_v2.standalone_rag_memory.MemoryTypeΒΆ

Bases: str, enum.Enum

Types of memories that can be stored.

Initialize self. See help(type(self)) for accurate signature.

class agents.memory_v2.standalone_rag_memory.MessageDocumentConverter(user_id=None, conversation_id=None)ΒΆ

Convert messages to documents for RAG storage.

Initialize converter.

Parameters:
  • user_id (str | None)

  • conversation_id (str | None)

convert_message(message)ΒΆ

Convert single message to document.

Parameters:

message (langchain_core.messages.BaseMessage)

Return type:

langchain_core.documents.Document

convert_messages(messages)ΒΆ

Convert multiple messages to documents.

Parameters:

messages (list[langchain_core.messages.BaseMessage])

Return type:

list[langchain_core.documents.Document]

class agents.memory_v2.standalone_rag_memory.PreferencesMemoryAgent(config, name='preferences_memory')ΒΆ

Memory agent for user preferences using SimpleRAGAgent for generation.

Initialize preferences memory agent.

Parameters:
async add_preference(preference)ΒΆ

Add a user preference.

Parameters:

preference (StandaloneMemoryItem)

Return type:

None

async get_preferences_for(context)ΒΆ

Get relevant preferences and generate summary.

Parameters:

context (str)

Return type:

str

async initialize()ΒΆ

Initialize the underlying RAG agent.

Return type:

None

class agents.memory_v2.standalone_rag_memory.StandaloneMemoryItem(/, **data)ΒΆ

Bases: pydantic.BaseModel

Standalone memory item for RAG-based storage.

Create a new model by parsing and validating input data from keyword arguments.

Raises [ValidationError][pydantic_core.ValidationError] if the input data cannot be validated to form a valid model.

self is explicitly positional-only to allow self as a field name.

Parameters:

data (Any)

mark_accessed()ΒΆ

Mark memory as accessed.

property age_hours: floatΒΆ

Get memory age in hours.

Return type:

float

model_configΒΆ

Configuration for the model, should be a dictionary conforming to [ConfigDict][pydantic.config.ConfigDict].

class agents.memory_v2.standalone_rag_memory.UnifiedMemoryRAGAgent(config, user_id=None)ΒΆ

Unified memory agent coordinating multiple specialized memory agents.

Initialize unified memory agent.

Parameters:
classmethod as_tool(name=None, description=None, **config_kwargs)ΒΆ

Convert this agent to a tool for use in other agents.

Parameters:
  • name (str | None)

  • description (str | None)

async get_memory_summary()ΒΆ

Get summary of all stored memories.

Return type:

dict[str, Any]

async initialize()ΒΆ

Initialize all memory agents.

Return type:

None

async process_conversation(messages)ΒΆ

Process conversation and extract memories.

Parameters:

messages (list[langchain_core.messages.BaseMessage])

Return type:

dict[str, Any]

async retrieve_context(query, memory_types=None)ΒΆ

Retrieve relevant context from all memory types.

Parameters:
Return type:

dict[str, Any]

agents.memory_v2.standalone_rag_memory.create_conversation_memory_agent(vector_store_provider=VectorStoreProvider.FAISS, embedding_model='sentence-transformers/all-mpnet-base-v2', enable_time_weighting=True, name='conversation_memory')ΒΆ

Factory function to create conversation memory agent.

Parameters:
  • vector_store_provider (haive.core.engine.vectorstore.VectorStoreProvider)

  • embedding_model (str)

  • enable_time_weighting (bool)

  • name (str)

Return type:

ConversationMemoryAgent

agents.memory_v2.standalone_rag_memory.create_unified_memory_agent(user_id=None, llm_config=None, vector_store_provider=VectorStoreProvider.FAISS, embedding_model='sentence-transformers/all-mpnet-base-v2')ΒΆ

Factory function to create unified memory agent.

Parameters:
  • user_id (str | None)

  • llm_config (haive.core.engine.aug_llm.AugLLMConfig)

  • vector_store_provider (haive.core.engine.vectorstore.VectorStoreProvider)

  • embedding_model (str)

Return type:

UnifiedMemoryRAGAgent

async agents.memory_v2.standalone_rag_memory.demo()ΒΆ

Demo.