Skip to main content

Attributes

The Memory system is configured through the Memory class, which provides the following attributes:
AttributeTypeDefaultDescription
storageStorage(required)Storage backend for memory persistence
session_idstr | NoneNoneSession identifier for conversation/summary memory
user_idstr | NoneNoneUser identifier for user analysis memory
full_session_memoryboolTrueEnable complete chat history
summary_memoryboolFalseEnable conversation summaries
user_analysis_memoryboolFalseEnable user learning and profiles
num_last_messagesint | NoneNoneLimit history to last N message turns
modelstr | Model | NoneNoneModel for analysis and summaries
user_profile_schemaBaseModel | NoneNoneCustom user profile schema
dynamic_user_profileboolTrueAllow agent to create custom profile fields
user_memory_modestr"update"User profile update mode: ‘update’ or ‘replace’
feed_tool_call_resultsboolFalseInclude tool calls in memory
debugboolFalseEnable debug logging

Configuration Example

from upsonic import Agent, Task, Memory
from upsonic.storage.providers.sqlite import SqliteStorage

# Create storage
storage = SqliteStorage("sessions", "profiles", "agent_memory.db")

# Create memory with configuration
memory = Memory(
    storage=storage,
    session_id="session_001",
    user_id="user_123",
    full_session_memory=True,
    summary_memory=True,
    user_analysis_memory=True,
    num_last_messages=20,
    model="openai/gpt-4o-mini",
    feed_tool_call_results=False,
    debug=True
)

# Create agent with memory
agent = Agent("openai/gpt-4o", memory=memory)

# Use agent - memory is automatic
task = Task("Hello! I'm interested in learning Python")
result = agent.do(task)
print(result)