Skip to main content

Overview

The Memory system uses two primary tables/collections to persist data:
  • Sessions Table: Stores conversation history, summaries, runs, and metadata
  • User Memory Table: Stores user profiles and extracted traits

Sessions Table Schema

Stores all session-related data including messages, runs, and summaries.
FieldTypeDescription
session_idstringPrimary key, unique session identifier
session_typestringType: "agent", "team", or "workflow"
agent_idstringAssociated agent ID
team_idstringAssociated team ID (for team sessions)
workflow_idstringAssociated workflow ID (for workflow sessions)
user_idstringUser identifier for cross-session tracking
messagesjsonFull conversation history (ModelRequest/ModelResponse)
summarystringGenerated session summary (if summary_memory=True)
runsjsonIndividual run outputs with status, requirements, usage
metadatajsonCustom session metadata
usagejsonUsage details for the session
created_atintegerUnix timestamp of creation
updated_atintegerUnix timestamp of last update

User Memory Table Schema

Stores user profiles and traits extracted from conversations.
FieldTypeDescription
user_idstringPrimary key, unique user identifier
user_memoryjsonExtracted user traits and preferences
agent_idstringAgent that extracted these traits (optional)
team_idstringTeam that extracted these traits (optional)
created_atintegerUnix timestamp of creation
updated_atintegerUnix timestamp of last update

Accessing Stored Data

Via Memory Class

from upsonic.storage.memory import Memory
from upsonic.storage.sqlite import SqliteStorage

storage = SqliteStorage(db_file="data.db")
memory = Memory(storage=storage, session_id="session_001")

# Get current session
session = memory.get_session()
print(session.messages)
print(session.summary)

# List all sessions for a user
sessions = memory.list_sessions(user_id="user_123")

Direct Storage Access

from upsonic.storage.sqlite import SqliteStorage

storage = SqliteStorage(db_file="data.db")

# Get session directly
session = storage.get_session(session_id="session_001", deserialize=True)

# Get user memory directly
user_memory = storage.get_user_memory(user_id="user_123", deserialize=True)
print(user_memory.user_memory)  # Dict of traits