Add Supermemory integration for Microsoft Agent Framework#775
Merged
graphite-app[bot] merged 1 commit intomainfrom Mar 10, 2026
Merged
Conversation
Deploying with
|
| Status | Name | Latest Commit | Updated (UTC) |
|---|---|---|---|
| ✅ Deployment successful! View logs |
supermemory-app | 984297b | Mar 10 2026, 01:53 AM |
Member
How to use the Graphite Merge QueueAdd the label Main to this PR to add it to the merge queue. You must have a Graphite account in order to use the merge queue. Sign up using this link. An organization admin has enabled the Graphite Merge Queue in this repository. Please do not merge from GitHub as this will restart CI on PRs being processed by the merge queue. This stack of pull requests is managed by Graphite. Learn more about stacking. |
da6c5d5 to
a3372b2
Compare
Prasanna721
approved these changes
Mar 9, 2026
Merge activity
|
## Summary This PR introduces comprehensive Supermemory integration for the Microsoft Agent Framework, providing three complementary approaches to add persistent memory capabilities to agents: middleware for automatic memory injection, context providers for session-based memory management, and tools for explicit memory operations. ## Key Changes - **SupermemoryChatMiddleware**: Automatic memory injection middleware that fetches relevant memories from Supermemory before LLM calls and optionally saves conversations. Supports three modes: - `"profile"`: Injects all static and dynamic profile memories - `"query"`: Searches for memories relevant to the current user message - `"full"`: Combines both profile and query modes - **SupermemoryContextProvider**: Idiomatic context provider following the Agent Framework pattern (similar to built-in Mem0 integration). Integrates with the session pipeline via `before_run()` and `after_run()` hooks for automatic memory retrieval and storage. - **SupermemoryTools**: FunctionTool-compatible tools that agents can use for explicit memory operations: - `search_memories()`: Search for specific memories - `add_memory()`: Add new memories - `get_profile()`: Retrieve user profile - **Utility Functions**: Helper functions for: - Memory deduplication across static, dynamic, and search result sources - Profile-to-markdown conversion for LLM consumption - Message extraction and conversation formatting - Logging with configurable verbosity - **Exception Hierarchy**: Custom exceptions for better error handling: - `SupermemoryConfigurationError`: Missing/invalid configuration - `SupermemoryAPIError`: API request failures - `SupermemoryNetworkError`: Network connectivity issues - `SupermemoryMemoryOperationError`: Memory operation failures - **Comprehensive Documentation**: README with quick start examples, configuration options, and API reference for all three integration approaches. - **Test Suite**: Unit tests covering middleware, context provider, tools, and utility functions with proper mocking and error scenarios. ## Implementation Details - Supports both async (aiohttp) and sync (requests) HTTP clients with automatic fallback - Handles multiple message formats (dict, objects with attributes, content arrays) - Configurable memory storage with optional conversation grouping via `conversation_id` - Environment variable fallback for API key configuration (`SUPERMEMORY_API_KEY`) - Background task management for non-blocking memory operations in middleware - Proper async/sync compatibility for the Supermemory SDK https://claude.ai/code/session_012idB5y6UGK3zmeFULgTc4z
c6e7bdc to
984297b
Compare
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.

Summary
This PR introduces comprehensive Supermemory integration for the Microsoft Agent Framework, providing three complementary approaches to add persistent memory capabilities to agents: middleware for automatic memory injection, context providers for session-based memory management, and tools for explicit memory operations.
Key Changes
SupermemoryChatMiddleware: Automatic memory injection middleware that fetches relevant memories from Supermemory before LLM calls and optionally saves conversations. Supports three modes:
"profile": Injects all static and dynamic profile memories"query": Searches for memories relevant to the current user message"full": Combines both profile and query modesSupermemoryContextProvider: Idiomatic context provider following the Agent Framework pattern (similar to built-in Mem0 integration). Integrates with the session pipeline via
before_run()andafter_run()hooks for automatic memory retrieval and storage.SupermemoryTools: FunctionTool-compatible tools that agents can use for explicit memory operations:
search_memories(): Search for specific memoriesadd_memory(): Add new memoriesget_profile(): Retrieve user profileUtility Functions: Helper functions for:
Exception Hierarchy: Custom exceptions for better error handling:
SupermemoryConfigurationError: Missing/invalid configurationSupermemoryAPIError: API request failuresSupermemoryNetworkError: Network connectivity issuesSupermemoryMemoryOperationError: Memory operation failuresComprehensive Documentation: README with quick start examples, configuration options, and API reference for all three integration approaches.
Test Suite: Unit tests covering middleware, context provider, tools, and utility functions with proper mocking and error scenarios.
Implementation Details
conversation_idSUPERMEMORY_API_KEY)https://claude.ai/code/session_012idB5y6UGK3zmeFULgTc4z