google / google/adk-python-community

feat(memory): add MongoDBMemoryService with Atlas Vector Search support

オープン
#169 コメント 0 件 リアクション 1 件 担当者 0 名 GitHub で見る
主要言語
Python
スター
182
フォーク
75
PR マージ指標
30日以内にマージされた PR はありません

説明

## Motivation

The community repo has memory service proposals for Valkey (#155/#156), Milvus (#69), Firestore (#38), and SQL backends (#99), but no MongoDB-backed memory service. MongoDB is one of the most widely deployed document databases, and MongoDB Atlas provides native vector search (`$vectorSearch`), making it a natural backend for agent long-term memory with semantic recall.

Related: #31/#32 add a MongoDB *session* service. This proposal is complementary — a `MemoryService` implementation for long-term memory retrieval, not session/state storage. If #32 merges, the two modules together would give ADK users a full MongoDB persistence story.

## Proposed API

A `MongoDBMemoryService` implementing ADK's `BaseMemoryService` interface:

- `add_session_to_memory(session)` — extracts session events, generates embeddings via a pluggable embedding function, and stores documents (`app_name`, `user_id`, `session_id`, `content`, `embedding`, `timestamp`) in a configurable collection
- `search_memory(app_name, user_id, query)` — semantic retrieval via Atlas `$vectorSearch` with top-k limits, similarity threshold, and app/user isolation via pre-filters; falls back to Atlas text search for deployments without a vector index

Configuration options: connection string, database/collection names, embedding function, vector index name, `top_k`, similarity threshold.

## Dependencies

- `pymongo>=4.15,<5.0` (matching the pin in #32) as an optional dependency under a `[mongodb]` extra

## Testing Plan

- Unit tests (mocked client): cover all public methods, edge cases, error conditions
- Integration tests: run against the `mongodb/mongodb-atlas-local` Docker image (supports vector search locally), covering vector similarity search, user/app isolation, top-k limits, distance threshold filtering, metadata preservation, and index idempotency

---

I'd like to implement this myself and will follow the module structure and contribution lifecycle in CONTRIBUTING.md. Happy to adjust the approach based on maintainer feedback.

コントリビューションガイド

コントリビューションガイドを開く

調査の方向性

CONTRIBUTING.md と BaseMemoryService インターフェース周辺の既存のモジュール構成から始めます。提案されているパブリックメソッド、オプションの pymongo 依存関係、モックおよび Atlas-local Docker を使ったテスト計画を確認します。MongoDB メモリサービスが、列挙された取得、分離、フィルタリング、メタデータ、エラー、インデックスの各動作を網羅すれば完了です。

索引モデルが issue の本文から書いたものです。

評価

技術スタック
docker, mongodb, python
領域
backend, databases
issue の種類
機能追加
難易度
5/5
見積もり時間
1週間以上
活発さ
静か
明瞭さ
おおむね明確
初心者へのやさしさ
35/100

新しい issue をメールで受け取る

初心者向けの GitHub issue を短くまとめたダイジェスト。