agents.memory_v2.rag_memory_agentΒΆ

RAG-based Memory Agent using BaseRAGAgent with advanced retrievers.

This module provides memory-capable agents built on BaseRAGAgent with: 1. Time-weighted retrieval for temporal memory access 2. Multi-modal memory storage (conversation, preferences, facts) 3. Knowledge graph-enhanced retrieval 4. Real-time memory updates and ingestion 5. Vector store persistence across different backends

All built using BaseRAGAgent as the foundation with custom retrievers.

ClassesΒΆ

ConversationMemoryAgent

Memory agent for conversation history using BaseRAGAgent.

FactualMemoryAgent

Memory agent for factual information using BaseRAGAgent.

MemoryRAGConfig

Configuration for RAG-based memory agents.

PreferencesMemoryAgent

Memory agent for user preferences using BaseRAGAgent.

UnifiedMemoryRAGAgent

Unified memory agent coordinating multiple specialized memory agents.

FunctionsΒΆ

create_conversation_memory_agent([...])

Factory function to create conversation memory agent.

create_factual_memory_agent([vector_store_provider, ...])

Factory function to create factual memory agent.

create_postgresql_memory_agent(connection_string[, ...])

Create memory agent with PostgreSQL persistence.

create_supabase_memory_agent(supabase_url, supabase_key)

Create memory agent with Supabase persistence.

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

Factory function to create unified memory agent.

demo()

Demo.

Module ContentsΒΆ

class agents.memory_v2.rag_memory_agent.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.rag_memory_agent.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[agents.memory_v2.memory_state_original.EnhancedMemoryItem])

Return type:

None

async add_memory(memory)ΒΆ

Add a factual memory.

Parameters:

memory (agents.memory_v2.memory_state_original.EnhancedMemoryItem)

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.rag_memory_agent.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.rag_memory_agent.PreferencesMemoryAgent(config, name='preferences_memory')ΒΆ

Memory agent for user preferences using BaseRAGAgent.

Initialize preferences memory agent.

Parameters:
async add_preference(preference)ΒΆ

Add a user preference.

Parameters:

preference (agents.memory_v2.memory_state_original.EnhancedMemoryItem)

Return type:

None

async check_preference_conflict(new_preference)ΒΆ

Check if new preference conflicts with existing ones.

Parameters:

new_preference (str)

Return type:

dict[str, Any]

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.rag_memory_agent.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.rag_memory_agent.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.rag_memory_agent.create_factual_memory_agent(vector_store_provider=VectorStoreProvider.FAISS, embedding_model='sentence-transformers/all-mpnet-base-v2', similarity_threshold=0.7, name='factual_memory')ΒΆ

Factory function to create factual memory agent.

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

  • embedding_model (str)

  • similarity_threshold (float)

  • name (str)

Return type:

FactualMemoryAgent

agents.memory_v2.rag_memory_agent.create_postgresql_memory_agent(connection_string, user_id=None, table_name='user_memories')ΒΆ

Create memory agent with PostgreSQL persistence.

Parameters:
  • connection_string (str)

  • user_id (str | None)

  • table_name (str)

Return type:

UnifiedMemoryRAGAgent

agents.memory_v2.rag_memory_agent.create_supabase_memory_agent(supabase_url, supabase_key, user_id=None)ΒΆ

Create memory agent with Supabase persistence.

Parameters:
  • supabase_url (str)

  • supabase_key (str)

  • user_id (str | None)

Return type:

UnifiedMemoryRAGAgent

agents.memory_v2.rag_memory_agent.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.rag_memory_agent.demo()ΒΆ

Demo.