Closed
Conversation
Add GoodmemChatPlugin for persistent conversation memory using Goodmem.ai service. The plugin automatically logs user messages and LLM responses, retrieves relevant historical context, and augments prompts with memory. Features: - Auto-logging of text messages and file attachments to Goodmem spaces - Context retrieval using semantic search with configurable top-k - Per-user memory isolation with automatic space management - Comprehensive error handling and debug mode - Support for binary attachments (PDFs, images, etc.) File structure: . ├── src/google/adk_community/ │ ├── __init__.py (modified: added plugins import) │ └── plugins/ │ ├── __init__.py (new: module exports) │ └── goodmem.py (new: 736 lines, plugin implementation) │ ├── tests/unittests/ │ └── plugins/ │ ├── __init__.py (new: test module) │ └── test_goodmem.py (new: 31 unit tests, 725 lines) │ ├── contributing/samples/goodmem/ │ ├── README.md (new: overview and setup guide) │ ├── PLUGIN.md (new: detailed plugin documentation) │ └── agent.py (new: sample agent with plugin) │ └── pyproject.toml (modified: added requests dependency) Test coverage: 31/31 tests passing (100%) - 8 tests for GoodmemClient (API operations) - 23 tests for GoodmemChatPlugin (lifecycle, callbacks, error handling) Related: Follows patterns from OpenMemory (PR google#36) and Redis Sessions (PR google#32)
- Create goodmem_client.py with GoodmemClient class - Update goodmem.py to import GoodmemClient from goodmem_client - Export GoodmemClient from plugins/__init__.py - Makes GoodmemClient reusable for both plugin and tool implementations
Move goodmem.py and goodmem_client.py into plugins/goodmem/ subdirectory and update all imports throughout the codebase. Replaced old goodmem_client.py with the version from tools branch. All unit tests pass (31/31). . ├── src/google/adk_community/ │ ├── __init__.py (modified: added plugins import) │ └── plugins/ │ ├── __init__.py (modified: updated imports to use goodmem submodule) │ └── goodmem/ │ ├── __init__.py (new: module exports) │ ├── goodmem_client.py (replaced: from tools branch, 274 lines) │ └── goodmem.py (moved: from plugins/ to plugins/goodmem/, 593 lines) │ ├── tests/unittests/ │ └── plugins/ │ └── test_goodmem.py (modified: updated imports and patch paths, 31 tests) │ ├── contributing/samples/goodmem/ │ ├── PLUGIN.md (modified: removed GoodmemClient section, added file tree) │ └── goodmem_plugin_demo/ │ └── agent.py (restored: was deleted in c8a1642 by bashareid, now restored) Legend: (M) = Modified, (A) = Added, (R) = Moved/Replaced
Critical fixes: - Fix cross-user data leakage in after_model_callback by calling _ensure_chat_space() - Replace assert statements with ValueError for python -O compatibility Major fixes: - Remove conflicting prompt rules (do not mention memory vs mention goodmem.ai) - Fix memory block order inconsistency (now consistently appends context) - Fix typo "memmory" -> "memory" Medium fixes: - Guard against empty contents list IndexError in _extract_user_content - Fix numeric fields sent as strings in create_space (1.0, 512, 64) - Fix debug mode behavioral difference (early return now outside debug block) Minor fixes: - Fix base_url documentation (should exclude /v1 suffix) Tests added: - test_multi_user_isolation: Verifies no cross-user data leakage - test_debug_mode_empty_retrieval_consistency: Ensures debug doesn't alter behavior - test_concurrent_user_race_condition: Simulates async race condition Tests updated: - Update validation error expectations (AssertionError -> ValueError) - Update empty chunks behavior (early return, no memory injection) - Update after_model_callback to verify _ensure_chat_space is called Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
Critical Security Fixes: - Eliminate cross-user data leakage by removing shared instance state (self.space_id and self._user_space_cache) - Implement _get_space_id() using session state for per-request isolation - All callbacks now use local variables instead of shared instance state Major Bug Fixes: - Remove conflicting prompt rules about memory attribution - Fix memory block order inconsistency (now consistently appends) - Fix debug mode behavioral difference with empty retrieval - Remove typo "memmory" in prompt text - Fix base_url documentation (should not include /v1 suffix) Medium Priority Fixes: - Replace assert statements with ValueError for python -O compatibility - Guard against empty contents list in _extract_user_content() - Change numeric fields from strings to proper types (int/float) - Ensure after_model_callback calls _get_space_id() before logging Performance Improvements: - Implement multipart/form-data upload for binary files - Remove base64 encoding overhead (33% size reduction) - Support files up to ~1GB instead of ~750MB limit - Strip trailing slash from base_url to prevent double-slash URLs Code Quality: - Replace Any type hints with proper ADK types (InvocationContext, CallbackContext, LlmRequest, LlmResponse, types.Content) - Add debug messages with pretty-printed JSON (2-space indent) - Fix deprecated datetime.utcfromtimestamp() to use timezone-aware version Tests: - Update all tests to work with session state instead of instance cache - Update binary upload test to verify multipart format - Fix async mock in concurrent race condition test - All 34 tests passing Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
Collaborator
Author
|
This one is ready to be submit to Google. |
- Rewrite PLUGIN.md for better structure: add callback flow section, reorganize prerequisites, expand limitations with specific values - Fix incorrect docstring (ValueError not AssertionError) - Document stdout side effect in goodmem_client - Clarify README.md branch locations
bashareid
reviewed
Jan 28, 2026
Collaborator
Author
|
Close this branch as we are using |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
PLEASE DO NOT MERGE THIS PR. This PR is for GoodMem team to clearly see what files are changed/added. Later, we will create a formal PR and submitted to google's adk-python-community repo.
GOODMEM TEAM: Please make changes in the
pluginbranch.Add GoodmemChatPlugin for persistent conversation memory using Goodmem.ai
service. The plugin automatically logs user messages and LLM responses,
retrieves relevant historical context, and augments prompts with memory.
Features:
File structure:
Test coverage: 31/31 tests passing (100%)
Related: Follows patterns from OpenMemory (PR google#36) and Redis Sessions (PR google#32)