Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,7 @@ sqlalchemy = ["SQLAlchemy>=2.0", "asyncpg>=0.29.0"]
encrypt = ["cryptography>=45.0, <46"]
redis = ["redis>=7"]
dapr = ["dapr>=1.16.0", "grpcio>=1.60.0"]
mongodb = ["pymongo>=4.14"]
docker = ["docker>=6.1"]
blaxel = ["blaxel>=0.2.50", "aiohttp>=3.12,<4"]
daytona = ["daytona>=0.155.0"]
Expand Down Expand Up @@ -90,6 +91,7 @@ dev = [
"grpcio>=1.60.0",
"testcontainers==4.12.0", # pinned to 4.12.0 because 4.13.0 has a warning bug in wait_for_logs, see https://github.com/testcontainers/testcontainers-python/issues/874
"pyright==1.1.408",
"pymongo>=4.14",
]

[tool.uv.workspace]
Expand Down
13 changes: 13 additions & 0 deletions src/agents/extensions/memory/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
DaprSession,
)
from .encrypt_session import EncryptedSession
from .mongodb_session import MongoDBSession
from .redis_session import RedisSession
from .sqlalchemy_session import SQLAlchemySession

Expand All @@ -29,6 +30,7 @@
"DAPR_CONSISTENCY_STRONG",
"DaprSession",
"EncryptedSession",
"MongoDBSession",
"RedisSession",
"SQLAlchemySession",
]
Expand Down Expand Up @@ -117,4 +119,15 @@ def __getattr__(name: str) -> Any:
"Install it with: pip install openai-agents[dapr]"
) from e

if name == "MongoDBSession":
try:
from .mongodb_session import MongoDBSession # noqa: F401

return MongoDBSession
except ModuleNotFoundError as e:
raise ImportError(
"MongoDBSession requires the 'mongodb' extra. "
"Install it with: pip install openai-agents[mongodb]"
) from e

raise AttributeError(f"module {__name__} has no attribute {name}")
Loading