Agent Wealth HubFree public resources
中文 EN العربية

Back to catalog / Agent state

Continue an agent conversation across requests with a persistent session

Associate a persistent session with the same user or task so later runs can use relevant history without mixing users.

Goal

Continue the correct conversation state across calls while isolating users’ records.

Steps

  1. Define session ID creation, ownership, expiration, and deletion rules. [openai-sessions] [openai-context]
  2. Create a stable conversation ID with session=SQLiteSession("conversation_123", "conversations.db"); authorize session IDs when storage is shared. [openai-sessions] [openai-context]
  3. Call await Runner.run(agent, user_input, session=session) each turn; use RunConfig(session_settings=SessionSettings(limit=...)) to bound history. [openai-sessions] [openai-context]
  4. Delete expired sessions under a retention policy and minimize stored conversation data. [openai-sessions] [openai-context]
  5. Run a multi-turn test for two isolated users and confirm each sees only its own history. [openai-sessions] [openai-context]

How to verify

Multi-turn tests should preserve each user’s context and reject cross-user session access.

Troubleshooting

If history is missing or mixed, verify session-ID ownership and backend persistence before changing prompts.

Permissions

Prerequisites

Permissions

Limitations

`SQLiteSession` suits local persistence; multi-process deployments need a shared session backend. A Session cannot be combined with server-managed `conversation_id` or `previous_response_id`.

Pinned upstream source

https://github.com/openai/openai-agents-python/blob/f53c62451c7f34c15f0c87fa745e05404025420f/docs/ref/memory/session.md

Repository
openai/openai-agents-python
File path
docs/ref/memory/session.md
Pinned commit
f53c62451c7f34c15f0c87fa745e05404025420f
Source checked
2026-10-14 · Reviewed against the pinned upstream source

Repository metrics

These values describe the upstream repository, not popularity or likes for an individual skill or playbook.

Stars
Not collected
Forks
Not collected
Observed at
Not collected

No metrics snapshot is available yet.

License: MIT

Main topic

Turn ecommerce campaign materials into a reviewable weekly brief

Related resources