Skip to main content

Documentation Index

Fetch the complete documentation index at: https://docs.upsonic.ai/llms.txt

Use this file to discover all available pages before exploring further.

Overview

Summary Memory generates and maintains an evolving summary of key conversation points. It works both alongside conversation memory and independently.

Save vs Load

FlagPurpose
summary_memorySave: Generate and persist session summaries
load_summary_memoryLoad: Inject summary into subsequent runs (defaults to summary_memory)

Standalone Usage

Summary memory works without full session memory. The agent recalls context through generated summaries instead of raw message history:
from upsonic import Agent, Task
from upsonic.storage.memory import Memory
from upsonic.storage.sqlite import SqliteStorage

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

memory = Memory(
    storage=storage,
    session_id="session_001",
    full_session_memory=False,  # No raw history
    summary_memory=True,        # Summary generated after each run
    model="anthropic/claude-sonnet-4-5"
)

agent = Agent("anthropic/claude-sonnet-4-5", memory=memory)

result1 = agent.do(Task("My name is Alice and I work on project Falcon"))
result2 = agent.do(Task("What project am I working on?"))
print(result2)  # Recalls via summary

Combined with Conversation Memory

Use both for detailed context + cost-efficient summaries:
from upsonic import Agent, Task
from upsonic.storage.memory import Memory
from upsonic.storage.sqlite import SqliteStorage

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

memory = Memory(
    storage=storage,
    session_id="session_001",
    full_session_memory=True,
    summary_memory=True,
    num_last_messages=10,  # Recent history + summary for older context
    model="anthropic/claude-sonnet-4-5"
)

agent = Agent("anthropic/claude-sonnet-4-5", memory=memory)

result = agent.do(Task("Continue our database optimization discussion"))
print(result)

Save History, Load Summary Only

Save full history for auditing but only inject the summary to reduce token usage:
from upsonic import Agent, Task
from upsonic.storage.memory import Memory
from upsonic.storage.sqlite import SqliteStorage

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

memory = Memory(
    storage=storage,
    session_id="session_001",
    full_session_memory=True,         # Save raw history
    summary_memory=True,              # Save summaries
    load_full_session_memory=False,   # Don't inject raw history
    load_summary_memory=True,         # Inject summary only
    model="anthropic/claude-sonnet-4-5"
)

agent = Agent("anthropic/claude-sonnet-4-5", memory=memory)

result1 = agent.do(Task("Let's discuss Python web frameworks"))
result2 = agent.do(Task("How does Django compare to Flask?"))
result3 = agent.do(Task("What have we discussed so far?"))
print(result3)  # Uses summary for context, full history saved in storage

How It Works

  1. After each completed run, the session summary is updated by a sub-agent
  2. Summary includes key points, user preferences, and topics discussed
  3. Summary is injected as context for subsequent interactions (when load_summary_memory is enabled)
  4. Works independently of full_session_memory — can be the sole source of recall

Parameters

ParameterTypeDefaultDescription
summary_memoryboolFalseSave and generate summaries
load_summary_memorybool | NoneNoneInject summary into runs (defaults to summary_memory)
session_idstrauto-generatedSession identifier
modelstr | Model(required)Model for generating summaries