Skip to content

Commit 053dbc4

Browse files
authored
Document OpenAI Conversations session option (#1649)
## Summary - document the OpenAI Conversations session option on the sessions guide - link to the generated reference page for the OpenAI Conversations session implementation - check in the generated reference stubs created during the docs build ## Testing - make build-docs ------ https://chatgpt.com/codex/tasks/task_i_68b80232666c83209c185fb761150b60
1 parent 6df6fe1 commit 053dbc4

File tree

4 files changed

+33
-1
lines changed

4 files changed

+33
-1
lines changed
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
# `Openai Conversations Session`
2+
3+
::: agents.memory.openai_conversations_session

docs/ref/memory/sqlite_session.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
# `Sqlite Session`
2+
3+
::: agents.memory.sqlite_session

docs/ref/models/default_models.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
# `Default Models`
2+
3+
::: agents.models.default_models

docs/sessions.md

Lines changed: 24 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -122,6 +122,27 @@ print(f"Agent: {result.final_output}")
122122
result = await Runner.run(agent, "Hello")
123123
```
124124

125+
### OpenAI Conversations API memory
126+
127+
Use the [OpenAI Conversations API](https://platform.openai.com/docs/guides/conversational-agents/conversations-api) to persist
128+
conversation state without managing your own database. This is helpful when you already rely on OpenAI-hosted infrastructure
129+
for storing conversation history.
130+
131+
```python
132+
from agents import OpenAIConversationsSession
133+
134+
session = OpenAIConversationsSession()
135+
136+
# Optionally resume a previous conversation by passing a conversation ID
137+
# session = OpenAIConversationsSession(conversation_id="conv_123")
138+
139+
result = await Runner.run(
140+
agent,
141+
"Hello",
142+
session=session,
143+
)
144+
```
145+
125146
### SQLite memory
126147

127148
```python
@@ -282,6 +303,7 @@ Use meaningful session IDs that help you organize conversations:
282303
- Use in-memory SQLite (`SQLiteSession("session_id")`) for temporary conversations
283304
- Use file-based SQLite (`SQLiteSession("session_id", "path/to/db.sqlite")`) for persistent conversations
284305
- Use SQLAlchemy-powered sessions (`SQLAlchemySession("session_id", engine=engine, create_tables=True)`) for production systems with existing databases supported by SQLAlchemy
306+
- Use OpenAI-hosted storage (`OpenAIConversationsSession()`) when you prefer to store history in the OpenAI Conversations API
285307
- Consider implementing custom session backends for other production systems (Redis, Django, etc.) for more advanced use cases
286308

287309
### Session management
@@ -378,4 +400,5 @@ For detailed API documentation, see:
378400

379401
- [`Session`][agents.memory.Session] - Protocol interface
380402
- [`SQLiteSession`][agents.memory.SQLiteSession] - SQLite implementation
381-
- [`SQLAlchemySession`][agents.extensions.memory.sqlalchemy_session.SQLAlchemySession] - SQLAlchemy-powered implementation
403+
- [`OpenAIConversationsSession`](ref/memory/openai_conversations_session.md) - OpenAI Conversations API implementation
404+
- [`SQLAlchemySession`][agents.extensions.memory.sqlalchemy_session.SQLAlchemySession] - SQLAlchemy-powered implementation

0 commit comments

Comments
 (0)