Skip to content

Commit 295dbb3

Browse files
Update docs
Signed-off-by: Aidan Jensen <[email protected]>
1 parent 67ad22d commit 295dbb3

File tree

5 files changed

+36
-3
lines changed

5 files changed

+36
-3
lines changed

docs/ref/extensions/memory.md

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
# `Memory Extensions`
2+
3+
::: agents.extensions.memory
4+
5+
options:
6+
members:
7+
- PostgreSQLSession

docs/sessions.md

Lines changed: 23 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -141,6 +141,27 @@ result = await Runner.run(
141141
)
142142
```
143143

144+
### PostgreSQL memory
145+
146+
```python
147+
from agents.extensions.memory import PostgreSQLSession
148+
from psycopg_pool import AsyncConnectionPool
149+
150+
# From a connection string (creates a new connection pool)
151+
session = PostgreSQLSession.from_connection_string("user_123", "postgresql://user:pass@host/db")
152+
153+
# From existing connection pool
154+
pool = AsyncConnectionPool(connection_string)
155+
session = PostgreSQLSession("user_123", pool)
156+
157+
# Use the session
158+
result = await Runner.run(
159+
agent,
160+
"Hello",
161+
session=session
162+
)
163+
```
164+
144165
### Multiple sessions
145166

146167
```python
@@ -221,7 +242,7 @@ Use meaningful session IDs that help you organize conversations:
221242

222243
- Use in-memory SQLite (`SQLiteSession("session_id")`) for temporary conversations
223244
- Use file-based SQLite (`SQLiteSession("session_id", "path/to/db.sqlite")`) for persistent conversations
224-
- Consider implementing custom session backends for production systems (Redis, PostgreSQL, etc.)
245+
- Consider implementing custom session backends for production systems (Redis, etc.)
225246

226247
### Session management
227248

@@ -317,3 +338,4 @@ For detailed API documentation, see:
317338

318339
- [`Session`][agents.memory.Session] - Protocol interface
319340
- [`SQLiteSession`][agents.memory.SQLiteSession] - SQLite implementation
341+
- [`PostgreSQLSession`][agents.extensions.memory.PostgrSQLSession] - PostgreSQL implementation

mkdocs.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -141,6 +141,7 @@ plugins:
141141
- ref/extensions/handoff_filters.md
142142
- ref/extensions/handoff_prompt.md
143143
- ref/extensions/litellm.md
144+
- ref/extensions/memory.md
144145

145146
- locale: ja
146147
name: 日本語
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
from .postgres_session import PostgreSQLSession
2+
3+
__all__ = ["PostgreSQLSession"]

tests/test_postgresql_session.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,10 +7,10 @@
77
from psycopg.rows import TupleRow
88
from psycopg_pool import AsyncConnectionPool
99

10-
from agents.extensions.memory.postgres_session import (
11-
MessageRow,
10+
from agents.extensions.memory import (
1211
PostgreSQLSession,
1312
)
13+
from agents.extensions.memory.postgres_session import MessageRow
1414
from agents.items import TResponseInputItem
1515

1616

0 commit comments

Comments
 (0)