Skip to content

Commit ae3263b

Browse files
authored
docs: normalize memory docstring cross-references (#3370)
1 parent e3c99d9 commit ae3263b

11 files changed

Lines changed: 159 additions & 140 deletions

File tree

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
# `Box`
2+
3+
::: agents.sandbox.entries.mounts.providers.box
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
# `Archive Ops`
2+
3+
::: agents.sandbox.session.archive_ops
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
# `Manifest Ops`
2+
3+
::: agents.sandbox.session.manifest_ops
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
# `Mount Lifecycle`
2+
3+
::: agents.sandbox.session.mount_lifecycle
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
# `Snapshot Lifecycle`
2+
3+
::: agents.sandbox.session.snapshot_lifecycle
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
# `Tar Workspace`
2+
3+
::: agents.sandbox.session.tar_workspace
Lines changed: 133 additions & 133 deletions
Original file line numberDiff line numberDiff line change
@@ -1,133 +1,133 @@
1-
"""Session memory backends living in the extensions namespace.
2-
3-
This package contains optional, production-grade session implementations that
4-
introduce extra third-party dependencies (database drivers, ORMs, etc.). They
5-
conform to the :class:`agents.memory.session.Session` protocol so they can be
6-
used as a drop-in replacement for :class:`agents.memory.session.SQLiteSession`.
7-
"""
8-
9-
from __future__ import annotations
10-
11-
from typing import TYPE_CHECKING, Any
12-
13-
if TYPE_CHECKING:
14-
from .advanced_sqlite_session import AdvancedSQLiteSession
15-
from .async_sqlite_session import AsyncSQLiteSession
16-
from .dapr_session import (
17-
DAPR_CONSISTENCY_EVENTUAL,
18-
DAPR_CONSISTENCY_STRONG,
19-
DaprSession,
20-
)
21-
from .encrypt_session import EncryptedSession
22-
from .mongodb_session import MongoDBSession
23-
from .redis_session import RedisSession
24-
from .sqlalchemy_session import SQLAlchemySession
25-
26-
__all__: list[str] = [
27-
"AdvancedSQLiteSession",
28-
"AsyncSQLiteSession",
29-
"DAPR_CONSISTENCY_EVENTUAL",
30-
"DAPR_CONSISTENCY_STRONG",
31-
"DaprSession",
32-
"EncryptedSession",
33-
"MongoDBSession",
34-
"RedisSession",
35-
"SQLAlchemySession",
36-
]
37-
38-
39-
def __getattr__(name: str) -> Any:
40-
if name == "EncryptedSession":
41-
try:
42-
from .encrypt_session import EncryptedSession # noqa: F401
43-
44-
return EncryptedSession
45-
except ModuleNotFoundError as e:
46-
raise ImportError(
47-
"EncryptedSession requires the 'cryptography' extra. "
48-
"Install it with: pip install openai-agents[encrypt]"
49-
) from e
50-
51-
if name == "RedisSession":
52-
try:
53-
from .redis_session import RedisSession # noqa: F401
54-
55-
return RedisSession
56-
except ModuleNotFoundError as e:
57-
raise ImportError(
58-
"RedisSession requires the 'redis' extra. "
59-
"Install it with: pip install openai-agents[redis]"
60-
) from e
61-
62-
if name == "SQLAlchemySession":
63-
try:
64-
from .sqlalchemy_session import SQLAlchemySession # noqa: F401
65-
66-
return SQLAlchemySession
67-
except ModuleNotFoundError as e:
68-
raise ImportError(
69-
"SQLAlchemySession requires the 'sqlalchemy' extra. "
70-
"Install it with: pip install openai-agents[sqlalchemy]"
71-
) from e
72-
73-
if name == "AdvancedSQLiteSession":
74-
try:
75-
from .advanced_sqlite_session import AdvancedSQLiteSession # noqa: F401
76-
77-
return AdvancedSQLiteSession
78-
except ModuleNotFoundError as e:
79-
raise ImportError(f"Failed to import AdvancedSQLiteSession: {e}") from e
80-
81-
if name == "AsyncSQLiteSession":
82-
try:
83-
from .async_sqlite_session import AsyncSQLiteSession # noqa: F401
84-
85-
return AsyncSQLiteSession
86-
except ModuleNotFoundError as e:
87-
raise ImportError(f"Failed to import AsyncSQLiteSession: {e}") from e
88-
89-
if name == "DaprSession":
90-
try:
91-
from .dapr_session import DaprSession # noqa: F401
92-
93-
return DaprSession
94-
except ModuleNotFoundError as e:
95-
raise ImportError(
96-
"DaprSession requires the 'dapr' extra. "
97-
"Install it with: pip install openai-agents[dapr]"
98-
) from e
99-
100-
if name == "DAPR_CONSISTENCY_EVENTUAL":
101-
try:
102-
from .dapr_session import DAPR_CONSISTENCY_EVENTUAL # noqa: F401
103-
104-
return DAPR_CONSISTENCY_EVENTUAL
105-
except ModuleNotFoundError as e:
106-
raise ImportError(
107-
"DAPR_CONSISTENCY_EVENTUAL requires the 'dapr' extra. "
108-
"Install it with: pip install openai-agents[dapr]"
109-
) from e
110-
111-
if name == "DAPR_CONSISTENCY_STRONG":
112-
try:
113-
from .dapr_session import DAPR_CONSISTENCY_STRONG # noqa: F401
114-
115-
return DAPR_CONSISTENCY_STRONG
116-
except ModuleNotFoundError as e:
117-
raise ImportError(
118-
"DAPR_CONSISTENCY_STRONG requires the 'dapr' extra. "
119-
"Install it with: pip install openai-agents[dapr]"
120-
) from e
121-
122-
if name == "MongoDBSession":
123-
try:
124-
from .mongodb_session import MongoDBSession # noqa: F401
125-
126-
return MongoDBSession
127-
except ModuleNotFoundError as e:
128-
raise ImportError(
129-
"MongoDBSession requires the 'mongodb' extra. "
130-
"Install it with: pip install openai-agents[mongodb]"
131-
) from e
132-
133-
raise AttributeError(f"module {__name__} has no attribute {name}")
1+
"""Session memory backends living in the extensions namespace.
2+
3+
This package contains optional, production-grade session implementations that
4+
introduce extra third-party dependencies (database drivers, ORMs, etc.). They
5+
conform to the [`Session`][agents.memory.session.Session] protocol so they can be
6+
used as a drop-in replacement for [`SQLiteSession`][agents.memory.sqlite_session.SQLiteSession].
7+
"""
8+
9+
from __future__ import annotations
10+
11+
from typing import TYPE_CHECKING, Any
12+
13+
if TYPE_CHECKING:
14+
from .advanced_sqlite_session import AdvancedSQLiteSession
15+
from .async_sqlite_session import AsyncSQLiteSession
16+
from .dapr_session import (
17+
DAPR_CONSISTENCY_EVENTUAL,
18+
DAPR_CONSISTENCY_STRONG,
19+
DaprSession,
20+
)
21+
from .encrypt_session import EncryptedSession
22+
from .mongodb_session import MongoDBSession
23+
from .redis_session import RedisSession
24+
from .sqlalchemy_session import SQLAlchemySession
25+
26+
__all__: list[str] = [
27+
"AdvancedSQLiteSession",
28+
"AsyncSQLiteSession",
29+
"DAPR_CONSISTENCY_EVENTUAL",
30+
"DAPR_CONSISTENCY_STRONG",
31+
"DaprSession",
32+
"EncryptedSession",
33+
"MongoDBSession",
34+
"RedisSession",
35+
"SQLAlchemySession",
36+
]
37+
38+
39+
def __getattr__(name: str) -> Any:
40+
if name == "EncryptedSession":
41+
try:
42+
from .encrypt_session import EncryptedSession # noqa: F401
43+
44+
return EncryptedSession
45+
except ModuleNotFoundError as e:
46+
raise ImportError(
47+
"EncryptedSession requires the 'cryptography' extra. "
48+
"Install it with: pip install openai-agents[encrypt]"
49+
) from e
50+
51+
if name == "RedisSession":
52+
try:
53+
from .redis_session import RedisSession # noqa: F401
54+
55+
return RedisSession
56+
except ModuleNotFoundError as e:
57+
raise ImportError(
58+
"RedisSession requires the 'redis' extra. "
59+
"Install it with: pip install openai-agents[redis]"
60+
) from e
61+
62+
if name == "SQLAlchemySession":
63+
try:
64+
from .sqlalchemy_session import SQLAlchemySession # noqa: F401
65+
66+
return SQLAlchemySession
67+
except ModuleNotFoundError as e:
68+
raise ImportError(
69+
"SQLAlchemySession requires the 'sqlalchemy' extra. "
70+
"Install it with: pip install openai-agents[sqlalchemy]"
71+
) from e
72+
73+
if name == "AdvancedSQLiteSession":
74+
try:
75+
from .advanced_sqlite_session import AdvancedSQLiteSession # noqa: F401
76+
77+
return AdvancedSQLiteSession
78+
except ModuleNotFoundError as e:
79+
raise ImportError(f"Failed to import AdvancedSQLiteSession: {e}") from e
80+
81+
if name == "AsyncSQLiteSession":
82+
try:
83+
from .async_sqlite_session import AsyncSQLiteSession # noqa: F401
84+
85+
return AsyncSQLiteSession
86+
except ModuleNotFoundError as e:
87+
raise ImportError(f"Failed to import AsyncSQLiteSession: {e}") from e
88+
89+
if name == "DaprSession":
90+
try:
91+
from .dapr_session import DaprSession # noqa: F401
92+
93+
return DaprSession
94+
except ModuleNotFoundError as e:
95+
raise ImportError(
96+
"DaprSession requires the 'dapr' extra. "
97+
"Install it with: pip install openai-agents[dapr]"
98+
) from e
99+
100+
if name == "DAPR_CONSISTENCY_EVENTUAL":
101+
try:
102+
from .dapr_session import DAPR_CONSISTENCY_EVENTUAL # noqa: F401
103+
104+
return DAPR_CONSISTENCY_EVENTUAL
105+
except ModuleNotFoundError as e:
106+
raise ImportError(
107+
"DAPR_CONSISTENCY_EVENTUAL requires the 'dapr' extra. "
108+
"Install it with: pip install openai-agents[dapr]"
109+
) from e
110+
111+
if name == "DAPR_CONSISTENCY_STRONG":
112+
try:
113+
from .dapr_session import DAPR_CONSISTENCY_STRONG # noqa: F401
114+
115+
return DAPR_CONSISTENCY_STRONG
116+
except ModuleNotFoundError as e:
117+
raise ImportError(
118+
"DAPR_CONSISTENCY_STRONG requires the 'dapr' extra. "
119+
"Install it with: pip install openai-agents[dapr]"
120+
) from e
121+
122+
if name == "MongoDBSession":
123+
try:
124+
from .mongodb_session import MongoDBSession # noqa: F401
125+
126+
return MongoDBSession
127+
except ModuleNotFoundError as e:
128+
raise ImportError(
129+
"MongoDBSession requires the 'mongodb' extra. "
130+
"Install it with: pip install openai-agents[mongodb]"
131+
) from e
132+
133+
raise AttributeError(f"module {__name__} has no attribute {name}")

src/agents/extensions/memory/dapr_session.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,7 @@
5555

5656

5757
class DaprSession(SessionABC):
58-
"""Dapr State Store implementation of :pyclass:`agents.memory.session.Session`."""
58+
"""Dapr State Store implementation of [`Session`][agents.memory.session.Session]."""
5959

6060
session_settings: SessionSettings | None = None
6161

src/agents/extensions/memory/mongodb_session.py

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,7 @@
6363

6464

6565
class MongoDBSession(SessionABC):
66-
"""MongoDB implementation of :pyclass:`agents.memory.session.Session`.
66+
"""MongoDB implementation of [`Session`][agents.memory.session.Session].
6767
6868
Conversation items are stored as individual documents in a ``messages``
6969
collection. A lightweight ``sessions`` collection tracks metadata
@@ -120,7 +120,7 @@ def __init__(
120120
messages_collection: Name of the collection that stores individual
121121
conversation items. Defaults to ``"agent_messages"``.
122122
session_settings: Optional session configuration. When ``None`` a
123-
default :class:`~agents.memory.session_settings.SessionSettings`
123+
default [`SessionSettings`][agents.memory.session_settings.SessionSettings]
124124
is used (no item limit).
125125
"""
126126
self.session_id = session_id
@@ -161,14 +161,15 @@ def from_uri(
161161
``"mongodb+srv://user:pass@cluster.example.com"``.
162162
database: Name of the MongoDB database to use.
163163
client_kwargs: Additional keyword arguments forwarded to
164-
:class:`pymongo.asynchronous.mongo_client.AsyncMongoClient`.
164+
`pymongo.asynchronous.mongo_client.AsyncMongoClient`.
165165
session_settings: Optional session configuration settings.
166166
**kwargs: Additional keyword arguments forwarded to the main
167167
constructor (e.g. ``sessions_collection``,
168168
``messages_collection``).
169169
170170
Returns:
171-
A :class:`MongoDBSession` connected to the specified MongoDB server.
171+
A [`MongoDBSession`][agents.extensions.memory.mongodb_session.MongoDBSession]
172+
connected to the specified MongoDB server.
172173
"""
173174
client_kwargs = client_kwargs or {}
174175
client_kwargs.setdefault("driver", _DRIVER_INFO)

src/agents/extensions/memory/redis_session.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@
4040

4141

4242
class RedisSession(SessionABC):
43-
"""Redis implementation of :pyclass:`agents.memory.session.Session`."""
43+
"""Redis implementation of [`Session`][agents.memory.session.Session]."""
4444

4545
session_settings: SessionSettings | None = None
4646

0 commit comments

Comments
 (0)