Skip to content

docs: add MongoDB session example under examples/memory#3036

Open
alexbevi wants to merge 2 commits intoopenai:mainfrom
alexbevi:mongodb-example
Open

docs: add MongoDB session example under examples/memory#3036
alexbevi wants to merge 2 commits intoopenai:mainfrom
alexbevi:mongodb-example

Conversation

@alexbevi
Copy link
Copy Markdown
Contributor

Summary

  • Adds examples/memory/mongodb_session_example.py to match the other backend examples in that directory (Redis, SQLAlchemy, Dapr, etc.) for MongoDBSession.
  • The example covers the standard three-turn conversation + session isolation flow, then highlights MongoDB-specific value: a shared AsyncMongoClient across concurrent sessions, multi-tenant collection isolation, an aggregation pipeline over stored messages, and a created_at TTL index for auto-expiry.

Adds an example under examples/memory that showcases MongoDBSession
for agent conversation memory. Beyond the basic session loop, the
example demonstrates MongoDB-specific strengths: sharing a single
AsyncMongoClient across sessions for production connection pooling,
multi-tenant collection isolation, aggregation pipelines over stored
conversation history, and TTL indexes for automatic expiration.
Use the latest MongoDB image tag in the example startup hint.
Copy link
Copy Markdown

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 4983bd849f

ℹ️ About Codex in GitHub

Codex has been enabled to automatically review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

When you sign up for Codex through ChatGPT, Codex can also answer questions or update the PR, like "@codex address that feedback".

Comment thread examples/memory/mongodb_session_example.py
Copy link
Copy Markdown
Member

@seratch seratch left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can we have only a simple example with a shared client? Sharing other examples on your own repo would be appreciated.

DATABASE = "agents_example"


async def main():
Copy link
Copy Markdown
Member

@seratch seratch Apr 27, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can we have only a simple example with a shared client? Sharing other examples on your own repo would be appreciated.

@seratch seratch added the documentation Improvements or additions to documentation label Apr 27, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

documentation Improvements or additions to documentation

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants