Agent Memory is a class that manages conversation history, session summaries, and long-term memories for AI agents. It provides comprehensive memory management capabilities including message tracking, run history, session summarization, and persistent memory storage.

Parameters

ParameterTypeDescriptionDefault
runsList[AgentRun]List of conversation runs between user and agent[]
messagesList[Message]List of messages sent to the model[]
update_system_message_on_changeboolWhether to update system message when changedFalse
summaryOptional[SessionSummary]Current session summaryNone
create_session_summaryboolWhether to create session summariesFalse
update_session_summary_after_runboolWhether to update summary after each runTrue
summarizerOptional[MemorySummarizer]Summarizer for generating session summariesNone
create_user_memoriesboolWhether to create personalized memoriesFalse
update_user_memories_after_runboolWhether to update memories after each runTrue
dbOptional[MemoryDb]Database for storing personalized memoriesNone
user_idOptional[str]User identifier for personalized memoriesNone
retrievalMemoryRetrievalMemory retrieval strategyMemoryRetrieval.last_n
memoriesOptional[List[Memory]]List of retrieved memoriesNone
num_memoriesOptional[int]Number of memories to retrieveNone
classifierOptional[MemoryClassifier]Classifier for memory importanceNone
managerOptional[MemoryManager]Manager for memory operationsNone

Agent Run

ParameterTypeDescriptionDefault
messageOptional[Message]Single message associated with the runNone
messagesOptional[List[Message]]List of messages associated with the runNone
responseOptional[RunResponse]Response generated during the runNone

Session Summary

ParameterTypeDescriptionDefault
summarystrConcise summary of the session focusing on important informationRequired
topicsOptional[List[str]]List of topics discussed in the sessionNone

Memory Summarizer

ParameterTypeDescriptionDefault
modelOptional[Model]Model used for generating summariesNone
use_structured_outputsboolWhether to use structured outputs from the modelFalse

Memory Retrieval

ParameterTypeDescription
last_nstrRetrieve the last N memories from history
first_nstrRetrieve the first N memories from history
semanticstrRetrieve memories based on semantic similarity

Memory

ParameterTypeDescriptionDefault
memorystrThe actual memory contentRequired
idOptional[str]Unique identifier for the memoryNone
topicOptional[str]Topic or category of the memoryNone
inputOptional[str]Original input that generated the memoryNone

Memory Classifier

ParameterTypeDescriptionDefault
modelOptional[Model]Model used for classifying memoriesNone
system_promptOptional[str]Custom system prompt for the classifierNone
existing_memoriesOptional[List[Memory]]List of existing memories to check againstNone

Memory Manager

ParameterTypeDescriptionDefault
modelOptional[Model]Model used for managing memoriesNone
user_idOptional[str]Unique identifier for the userNone
system_promptOptional[str]Custom system prompt for the memory managerNone
dbOptional[MemoryDb]Database for storing memoriesNone
input_messageOptional[str]Current input message being processedNone