Skip to main content
Storage lets your agent remember conversations. With the same session_id, it picks up where you left off, even after restarting.
1

Create a Python file

agent_with_storage.py
2

Set up your virtual environment

3

Install dependencies

4

Export your OpenAI API key

5

Run Agent

Key Concepts

  • Session: A conversation thread identified by session_id
  • Same session_id = continuous conversation, even across script runs
  • add_history_to_context=True: Includes previous messages in context
  • num_history_runs=5: Number of previous runs to include