Start fresh. The agent forgets.
A new session_id gives the agent a clean conversation, but nothing the same user said in an earlier chat comes with it.
The third option for agent memory
Start every conversation fresh without making your agent forget the user. Mem01Session remembers useful facts between chats and brings back only what matters now.
from mem01session import memSession
session = memSession(
session_id="chat-friday",
user_id="alex",
)
# Required for long-term recall on every run:
# run_config=session.run_config()One Session object. Current-chat history stays in SQLite. Long-term memory stays in your Postgres database. Installing mem01session pulls the mem01-engine distribution; the import path remains import mem01.
Choose the memory behavior
The right choice depends on whether your app needs to remember a person across separate conversations.
A new session_id gives the agent a clean conversation, but nothing the same user said in an earlier chat comes with it.
The agent can see earlier facts because every old message stays in the same conversation history. Limits and compaction can help, but this is still raw chat history.
Give each chat its own session_id and keep one stable user_id. Relevant facts can follow the user without replaying every previous conversation.
Fresh and reused Sessions remain reasonable choices when an app does not need cross-conversation user memory.
Quickstart
Install from PyPI, set two environment variables, and pass a fresh run_config() on every Runner.run so long-term recall can inject.
Python
3.11+ declared
Install
pip install mem01session
OpenAI
OPENAI_API_KEY
Store
Postgres + pgvector
pip install mem01session# Required
OPENAI_API_KEY=...
DATABASE_URL=postgresql://...
# Optional defaults
MEM01_LLM_MODEL=gpt-5.6-sol
MEM01_EMBEDDING_MODEL=text-embedding-3-smallPass a fresh session.run_config() on every Runner.run. session= alone keeps short-term SQLite history; it does not inject long-term beliefs. The merge callback captures the current query without creating persisted items. A later model-input filter injects bounded recalled memory into model input only.
from agents import Agent, Runner
from mem01session import memSession
agent = Agent(
name="Assistant",
instructions="Use supplied memory as evidence and acknowledge unknown personal facts.",
model="gpt-5.6-sol",
)
session = memSession(
session_id="chat-friday",
user_id="alex",
)
try:
result = await Runner.run(
agent,
"Where do I live now?",
session=session,
run_config=session.run_config(),
)
finally:
await session.close()Use a new value when the same user starts a new chat. SQLite stores exact messages for that conversation.
Keep it stable across chats. Mem01Session uses it for relevant long-term memories.
Synthetic memory is not saved to SQLite or sent back through extraction. There is no separate memory API service, container, port, or HTTP hop in the default path.
Optional source install for package development (editable siblings):
# Optional: develop from sibling source checkouts
cd mem01session
python -m venv .venv
source .venv/bin/activate
pip install -e "../mem01[openai]" -e "."Get hands-on
Use the published wheel for normal work, run the key-free deterministic demo when you want offline evidence, and browse the public source anytime.
1. Install
pip install mem01session
2. Configure
Set OPENAI_API_KEY and DATABASE_URL for live runs. The deterministic demo needs neither.
3. Deterministic demo
mem01session-demo (or python -m mem01session.demo) — key-free prepared-input evidence
4. Source
Public MIT repos: mem01session package and the mem01 engine it builds on
How it works
The Runner talks to one Session object; there is no separate memory API service, container, port, or HTTP hop in the default path.
Step 1
The SDK reads and writes current-chat items through the internal SDK SQLiteSession.
Step 2
After a complete user and assistant exchange, Mem01Session queues useful-fact extraction automatically in the embedded mem01 runtime. The answer can render while that user's FIFO write finishes in Postgres / pgvector.
Step 3
A stable user_id recalls relevant active memories as bounded model input. Synthetic memory is not copied into SQLite.
Concrete proof
Pass/fail is about prepared state and belief lifecycle. Model wording is an observation, not a product guarantee about every response.
Chat 1
The user lives in NYC and pays $2,400 in monthly rent.
Chat 2
The same user says they moved to San Francisco.
New chat
A fresh session_id asks where the user lives and what their earlier rent was.
Deterministic state (what must hold)
Example live-model wording (observation only)
“You now live in San Francisco. Your prior monthly rent was $2,400.”
“I don't have your sister's name stored.”
Fresh stock Session: a new session has no earlier-chat facts.
Reused stock Session: the answer can use all retained raw history.
Mem01Session with a fresh session_id: the answer uses relevant active memory for the same user.
Generated scaling artifact
These are local deterministic fake, offline prepared model input measurements. The estimator is a UTF-8 bytes upper bound, not provider usage or billed tokens.
| Strategy | Conversation 1 | Conversation 10 | Conversation 40 |
|---|---|---|---|
| Fresh stock Session | 1 items · 44 UTF-8 bytes upper bound | 1 items · 56 UTF-8 bytes upper bound | 1 items · 25 UTF-8 bytes upper bound |
| Reused stock Session | 1 items · 44 UTF-8 bytes upper bound | 19 items · 415 UTF-8 bytes upper bound | 79 items · 1898 UTF-8 bytes upper bound |
| Mem01Session | 2 items · 541 UTF-8 bytes upper bound | 2 items · 740 UTF-8 bytes upper bound | 2 items · 709 UTF-8 bytes upper bound |
Agents SDK 0.18.2 · answer model local-deterministic-fake · extraction local-deterministic-fixture-extractor · memory budget 800 bytes
Keep users in control
Developers can show what was remembered and respond to corrections or deletion requests. Raw chat history and long-term memory are separate, so clearing SQLite items does not reverse facts already extracted.
beliefs = await session.memory_history(
include_invalidated=True,
)
if beliefs:
await session.correct_memory(
beliefs[0].id,
"Lives in San Francisco",
)
await session.forget_memory(
"belief-to-remove",
reason="user requested deletion",
)
# Explicit barrier when your application needs durable completion now.
await session.flush_memory()
# Separate scopes: chat transcript vs durable user memory
await session.clear_session() # this chat's SQLite only
await session.clear_memory() # all durable beliefs for this user_idMemory is failure-open by default after raw persistence, with a sanitized error available for inspection. Set strict=True to raise enqueue failures immediately and background failures at the next same-user read or explicit flush.
Call await session.close() to drain accepted writes and release package-owned resources. Explicitly injected runtime or inner Session objects remain caller-owned.
Python 3.11+ is declared. This workspace is verified on macOS, Apple silicon, and Python 3.14.4; no broader platform matrix is claimed yet.
Evidence you can audit
The engine and the Agents SDK package answer different questions. Keep their measurements separate when you evaluate either surface.
Engine evidence
LoCoMo runs, the five-case staleness suite, Postgres recall latency, and packed-memory measurements describe the engine (mem01-engine). They are not the same as package integration tests for Mem01Session.
See engine researchPackage evidence
Published on PyPI as mem01session with dependency mem01-engine. Public GitHub, automated tests, wheel builds, a deterministic three-way demo, generated scaling artifact, and live GPT-5.6 runs on the Agents SDK Session path.
Integration comparison · reviewed 2026-07-12
Rows summarize the linked vendor or framework documentation as reviewed on the stated date; they are not universal performance rankings. Mem01Session’s differentiator is Session protocol plus belief lifecycle, not generic vector search alone.
| System / source | Integration | Memory shape | Lifecycle |
|---|---|---|---|
| Agents SDK Sessions | Framework Session | Raw history for one session ID | Backend history operations |
| mem0 Agents SDK integration | Memory tools | Semantic memory | Product-specific |
| Hindsight Agents SDK guide | Memory tools | Persistent memory | Product-specific |
| Mem01Session | Session plus framework hooks | Raw current chain plus beliefs | Supersede, correct, forget |
FAQ
Open source
Install the package from PyPI, browse the session repository, and open the engine repo when you want the underlying belief-memory system.