Skip to main content
Memory lets your agent remember facts about users across conversations. Unlike storage (which persists conversation history), memory stores user-level information like preferences and context.
1

Create a Python file

agent_with_memory.py
2

Set up your virtual environment

3

Install dependencies

4

Export your OpenAI API key

5

Run Agent

Memory vs Storage

Enabling Memory

  1. enable_agentic_memory=True (used above): Adds an update_user_memory tool. The model decides whether to call it. Existing memories are added to context.
  2. update_memory_on_run=True: Runs the memory manager for each non-empty user input. This adds a model call and does not guarantee that every detail becomes a memory.