feat: add Mengram memory integration#4595
Open
alibaizhanov wants to merge 3 commits intocrewAIInc:mainfrom
Open
feat: add Mengram memory integration#4595alibaizhanov wants to merge 3 commits intocrewAIInc:mainfrom
alibaizhanov wants to merge 3 commits intocrewAIInc:mainfrom
Conversation
Add MengramMemory as a drop-in replacement for CrewAI's Memory class, backed by Mengram's cloud API with semantic search, knowledge graph, episodic memory, and experience-driven procedural learning.
When the free plan quota is reached (HTTP 402), the crew continues working without memory instead of crashing. remember() silently skips writes, recall() returns empty results, and a single warning with upgrade URL is logged. Adds _QuotaExceededError, detection in _MengramClient._request(), and 13 new tests (76 total).
_recall_deep was using config.search_limit (default 5) instead of the caller's limit parameter for the API request. Now uses max(limit, config.search_limit) so recall(limit=50) fetches enough results per memory type. Adds regression test.
2a73e83 to
f438689
Compare
There was a problem hiding this comment.
Cursor Bugbot has reviewed your changes and found 1 potential issue.
Bugbot Autofix is OFF. To automatically fix reported issues with Cloud Agents, enable autofix in the Cursor dashboard.
Author
|
Hey, friendly ping — this is ready for review. Happy to address any feedback. |
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
MengramMemoryas a drop-in replacement for CrewAI'sMemoryclass, backed by Mengram's cloud APIMemoryinterface (same pattern as Hindsight PR feat: add Hindsight memory integration #4448) — pass directly toCrew(memory=mengram_memory)urllib) — self-contained HTTP clientFiles Changed
lib/crewai/src/crewai/memory/storage/mengram_storage.py_MengramClient,MengramConfig, result converters,MengramMemoryclass (~780 lines)lib/crewai/tests/storage/test_mengram_storage.pylib/crewai/pyproject.tomlmengram = ["mengram-ai>=2.15.0"]optional dependencydocs/en/concepts/memory.mdxUsage
How It Works
remember(content)→POST /v1/add_text— Mengram's extraction pipeline automatically discovers entities, facts, relationships, episodes, and proceduresrecall(query, depth="deep")→POST /v1/search/all— unified search across semantic + episodic + procedural memory with knowledge graph traversal and rerankingrecall(query, depth="shallow")→POST /v1/search— fast semantic-only searchreset()→DELETE /v1/memories/allThreadPoolExecutor,drain_writes()before everyrecall()No local LLM or embedder needed — Mengram handles extraction, embedding, and search server-side.
Quota Handling
When the Mengram free plan quota is exceeded (HTTP 402):
remember()silently skips writes — crew continues workingrecall()returns empty results — agents proceed without memory contextTest plan
pytest tests/storage/test_mengram_storage.py -v— 77 passed, 0 failedNote
Medium Risk
Adds a new networked memory backend with custom HTTP/retry and background-write logic; while isolated and optional, failures could affect memory availability and latency for adopters.
Overview
Adds a new optional Mengram memory backend (
MengramMemory) that duck-types the unifiedMemoryinterface so crews can use Mengram’s cloud API forremember/recall/reset(including async wrappers and backgroundremember_manywrites withdrain_writes()before recall).Introduces a small stdlib-only HTTP client with retries and explicit quota handling (HTTP 402) to degrade gracefully (skip writes / return empty recalls with a single warning). Also adds a
crewai[mengram]extra, comprehensive mocked unit tests for the backend/client, and documentation covering installation and configuration.Written by Cursor Bugbot for commit f438689. This will update automatically on new commits. Configure here.