Skip to main content
The Memory system in Upsonic provides comprehensive, configurable memory management for AI agents, enabling them to maintain context across conversations, build user profiles, and store session summaries.

Memory System Overview

The Memory class serves as a centralized module for managing different types of memory and respects the specific data formats and logic established in the original application design for handling chat history.

Key Features

  • Session Memory: Full conversation history storage and retrieval
  • Summary Memory: Automatic conversation summarization
  • User Analysis Memory: Dynamic user profile building and trait analysis
  • Flexible Storage: Support for various storage backends (SQLite, etc.)
  • Context Injection: Automatic injection of relevant memory into system prompts

Setting Up Memory with SQLite

Here’s how to set up memory with SQLite storage:

Memory Configuration Options

Basic Memory Setup

Full Memory Configuration

Memory Types Explained

Full Session Memory

Stores complete conversation history for context retrieval:

Summary Memory

Automatically generates and maintains conversation summaries:

User Analysis Memory

Builds and maintains user profiles based on interactions:

Using Memory in Task Execution

Once configured, memory automatically integrates with your agent:
The memory system will:
  1. Inject relevant user profile information into the system prompt
  2. Include conversation summaries for context
  3. Provide full conversation history if needed
  4. Update user profiles based on the interaction

Memory Management Methods

Accessing Memory Data

Memory Configuration in Agent

Advanced Memory Features

Custom User Profile Schema

Dynamic User Profile Generation

Memory with Limited History

Storage Configuration Options

The SqliteStorage class accepts the following parameters:

Best Practices

  1. Choose Appropriate Memory Types: Enable only the memory types you need to optimize performance
  2. Set Session IDs: Always provide meaningful session IDs for proper memory isolation
  3. User ID Management: Use consistent user IDs for proper profile building
  4. Model Provider: Provide a model provider for summary and analysis features
  5. Storage Backend: Choose appropriate storage backend based on your deployment needs
  6. Memory Limits: Use num_last_messages to prevent memory from growing too large
  7. Debug Mode: Enable debug mode during development to understand memory behavior
  8. Tool Results: Consider whether to include tool call results in memory based on your use case
The Memory system provides a robust foundation for building conversational AI applications that can maintain context, learn from interactions, and provide personalized experiences.