agents.memory_v2.conversation_memory_agent

Conversation Memory Agent using BaseRAGAgent.

This module provides conversation memory storage and retrieval using BaseRAGAgent with semantic search over conversation history and optional time-weighting.

Classes

ConversationMemoryAgent

Memory agent for conversation history using BaseRAGAgent.

ConversationMemoryConfig

Configuration for ConversationMemoryAgent.

MessageDocumentConverter

Convert messages to documents for RAG storage.

Functions

demo_conversation_memory()

Demo conversation memory agent functionality.

Module Contents

class agents.memory_v2.conversation_memory_agent.ConversationMemoryAgent(config=None, name='conversation_memory', user_id=None)

Memory agent for conversation history using BaseRAGAgent.

This agent provides: - Semantic search over conversation history - Automatic message-to-document conversion - Real BaseRAGAgent integration with vector stores - Incremental conversation updates - Time-weighted retrieval (optional)

Examples

Basic usage:

agent = ConversationMemoryAgent("user_123")
await agent.initialize()

# Add conversation
messages = [HumanMessage("I work at Google")]
await agent.add_conversation(messages)

# Retrieve context
docs = await agent.retrieve_context("Where do I work?")

Initialize conversation memory agent.

Parameters:
async add_conversation(messages)

Add conversation messages to memory.

Parameters:

messages (list[langchain_core.messages.BaseMessage])

Return type:

None

classmethod create(user_id=None, vector_store_provider=VectorStoreProvider.FAISS, embedding_model='sentence-transformers/all-mpnet-base-v2', name='conversation_memory')

Factory method to create ConversationMemoryAgent.

Parameters:
  • user_id (str | None)

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

  • embedding_model (str)

  • name (str)

Return type:

ConversationMemoryAgent

async get_conversation_summary()

Get summary of stored conversations.

Return type:

dict[str, Any]

async initialize()

Initialize the underlying RAG agent.

Return type:

None

async retrieve_context(query, k=None)

Retrieve relevant conversation context using BaseRAGAgent.

Parameters:
  • query (str) – Search query

  • k (int | None) – Number of documents to retrieve

Returns:

List of relevant conversation documents

Return type:

list[langchain_core.documents.Document]

class agents.memory_v2.conversation_memory_agent.ConversationMemoryConfig(/, **data)

Bases: pydantic.BaseModel

Configuration for ConversationMemoryAgent.

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.conversation_memory_agent.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]

async agents.memory_v2.conversation_memory_agent.demo_conversation_memory()

Demo conversation memory agent functionality.