feat(memory): Add SOS Memory Service integration#50
feat(memory): Add SOS Memory Service integration#50servathadi wants to merge 1 commit intogoogle:mainfrom
Conversation
Add SOSMemoryService for ADK, providing semantic memory with: - FRC Physics: Frequency-Recency-Context weighted retrieval - Lineage Tracking: Cryptographic hash chain for memory provenance - Multi-Agent Isolation: Agent-specific memory namespaces - Semantic Search: Vector-based similarity matching Components: - src/google/adk_community/memory/sos_memory_service.py - contributing/samples/sos_memory/ (sample agent) - tests/unittests/memory/test_sos_memory_service.py (20 tests) SOS (Sovereign Operating System) is an open-source agent orchestration framework: https://github.com/servathadi/sos 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
|
Thanks for your pull request! It looks like this may be your first contribution to a Google open source project. Before we can look at your pull request, you'll need to sign a Contributor License Agreement (CLA). View this failed invocation of the CLA check for more information. For the most up to date status, view the checks section at the bottom of the pull request. |
Summary of ChangesHello @servathadi, I'm Gemini Code Assist1! I'm currently reviewing this pull request and will post my feedback shortly. In the meantime, here's a summary to help you and other reviewers quickly get up to speed! This pull request significantly enhances the ADK's memory ecosystem by integrating with the SOS Mirror API. This integration provides agents with a sophisticated semantic memory backend that leverages FRC physics for highly relevant information retrieval, cryptographic lineage tracking for auditability, and isolated memory namespaces for multi-agent environments. The changes include the core service implementation, a configurable service class, a comprehensive sample agent, and robust unit tests. Highlights
🧠 New Feature in Public Preview: You can now enable Memory to help Gemini Code Assist learn from your team's feedback. This makes future code reviews more consistent and personalized to your project's style. Click here to enable Memory in your admin console. Changelog
Activity
Using Gemini Code AssistThe full guide for Gemini Code Assist can be found on our documentation page, here are some quick tips. Invoking Gemini You can request assistance from Gemini at any point by creating a comment using either
Customization To customize Gemini Code Assist for GitHub experience, repository maintainers can create a configuration file and/or provide a custom code review style guide (such as PEP-8 for Python) by creating and adding files to a Limitations & Feedback Gemini Code Assist may make mistakes. Please leave feedback on any instances where its feedback is incorrect or counter productive. You can react with 👍 and 👎 on @gemini-code-assist comments. If you're interested in giving your feedback about your experience with Gemini Code Assist for Github and other Google products, sign up here. You can also get AI-powered code generation, chat, as well as code reviews directly in the IDE at no cost with the Gemini Code Assist IDE Extension. Footnotes
|
There was a problem hiding this comment.
Code Review
This pull request introduces an integration with the SOS Memory Service, providing features like FRC-weighted memory retrieval and lineage tracking. The implementation is well-structured and includes a comprehensive set of unit tests and a sample agent.
My review focuses on improving the robustness and maintainability of the new service. I've suggested changes to:
- Decouple content from metadata to improve semantic search quality and simplify the code.
- Increase the length of the lineage hash to reduce collision risks and enhance auditability.
- Align the documentation with the implementation details.
Overall, this is a great addition to the ADK community memory services.
| metadata_parts = [] | ||
| if event.author: | ||
| metadata_parts.append(f"Author: {event.author}") | ||
| if timestamp_str: | ||
| metadata_parts.append(f"Time: {timestamp_str}") | ||
|
|
||
| if metadata_parts: | ||
| metadata_prefix = "[" + ", ".join(metadata_parts) + "] " | ||
| enriched_content = metadata_prefix + content_text |
There was a problem hiding this comment.
Prepending metadata to the content text can negatively impact the quality of semantic search, as the embeddings will be generated from this modified text instead of the pure content. This also makes the implementation more brittle, requiring parsing logic in _convert_to_memory_entry to extract the original content.
Since the author and timestamp are already being stored in the metadata dictionary, this text enrichment is redundant. I suggest removing this logic. This will lead to cleaner embeddings and a more robust implementation.
As a follow-up, the parsing logic in _convert_to_memory_entry (lines 247-258) can also be removed, as the fallback to the metadata dictionary will handle retrieving the author and timestamp.
| Every memory gets a lineage hash: | ||
|
|
||
| ```python | ||
| hash = SHA256(previous_hash + agent_id + content + context)[:16] |
There was a problem hiding this comment.
The formula for the lineage hash in the README is slightly different from the actual implementation. The implementation uses colons to separate the components of the string being hashed. To avoid confusion, it would be best to update the example to reflect this.
| hash = SHA256(previous_hash + agent_id + content + context)[:16] | |
| hash = SHA256(f"{previous_hash}:{agent_id}:{content}:{context}")[:16] |
| """Compute a lineage hash for memory provenance tracking.""" | ||
| prev_hash = self._lineage_chain[-1] if self._lineage_chain else "genesis" | ||
| data = f"{prev_hash}:{self._agent_id}:{content}:{context}" | ||
| return hashlib.sha256(data.encode()).hexdigest()[:16] |
There was a problem hiding this comment.
Truncating the SHA256 hash to 16 characters (64 bits) increases the risk of hash collisions, which could compromise the integrity of the lineage tracking for auditability purposes. For a 64-bit hash, a collision becomes likely after around 2^32 (about 4 billion) entries. To improve robustness and reduce the chance of collisions, consider using a larger portion of the hash, for example, 32 characters (128 bits).
| return hashlib.sha256(data.encode()).hexdigest()[:16] | |
| return hashlib.sha256(data.encode()).hexdigest()[:32] |
Summary
Adds SOSMemoryService - a memory service integration for SOS (Sovereign Operating System), an open-source agent orchestration framework.
Features
Components Added
src/google/adk_community/memory/sos_memory_service.pycontributing/samples/sos_memory/tests/unittests/memory/test_sos_memory_service.pyUsage Example
Value Proposition
Test Plan
🤖 Generated with Claude Code