by beersoccer ยท v0.3.1
Self-hosted mode mem0 plugin, async_mode enabled by default. Write ops (Add/Update/Delete) are non-blocking in async mode, Read ops (Search/Get/History) always wait; in sync mode all operations block. Supports dynamic log level configuration. Performance optimizations: smart memory classification (33% LLM call reduction), token-aware processing with tiktoken.
This community listing does not yet include every recommended support, privacy, pricing, and permission disclosure. Review the available package permissions before installing.
Available inside your emploidai workspace after installation.
Available inside your emploidai workspace after installation.
Last updated: 2026-05-16
A comprehensive Dify plugin that integrates Mem0 AI's intelligent memory layer, providing self-hosted mode tools with a unified client for self-hosted setups. View on GitHub
async_mode is enabled by default; Write ops (Add/Update/Delete) are non-blocking in async mode, Read ops (Search/Get/History) always wait; in sync mode all operations block until completion.asyncio.WindowsSelectorEventLoopPolicy() on Windows at plugin startupWRITE_OPERATION_TIMEOUT from 15 s to 45 s to reduce silent write failures on slower LLM providersollama dependency so the API-key validation screen no longer hangs when Ollama is selectedmistral provider entry that caused silent failures during credential validationextract_long_term_memory parameters to form: llm so Dify can bind system variables and upstream values more consistentlycohere>=6.1.0 runtime dependency and clarified SDK expectations for cloud rerankers in the docsAsyncMemory.from_config(...) so async mode now works whether mem0 exposes it as a coroutine-returning API or a regular classmethodmem0ai dependency range to >=1.0.2,<=1.0.111.0.2 while allowing explicit future validation within the supported rangefrom_config semantics and async provider credential validationThese changes fix the async-mode startup regression against newer mem0 releases while keeping installation and release documentation aligned.
distance vs similarity) by vector provider/metric and normalized search outputs to stable 0-1 similaritysearch_memory results now consistently expose score (similarity), vector_distance, and rerank_scoreforget_memories tool with dry_run preview supportmemory_ttl_days (optional hard memory TTL) and checkpoint_ttl_days (checkpoint cleanup TTL, default 90)These changes improve cross-backend retrieval consistency and establish a controllable memory lifecycle for long-term operation.
asyncio.as_completed with a true Semaphore sliding window; a slow user no longer blocks the next one from starting (straggler problem eliminated)These changes improve extraction throughput and resource utilization for large user batches; the global concurrency ceiling across multiple concurrent extraction tasks remains unchanged.
For full historical details, see CHANGELOG.md.
๐ For detailed installation steps, see CONFIG.md - Installation
Settings โ PluginsInstall from GitHub or upload the plugin package.difypkg fileInstall๐ For detailed configuration steps and examples, see CONFIG.md - Configuration Steps
After installation, you need to configure:
local_llm_json_secret, local_embedder_json_secret, local_vector_db_json_secretlocal_graph_db_json_secret, local_reranker_json_secretmax_concurrent_memory_operations
minconn, maxconn) are configured in the vector store JSON config, not as separate credential fieldsheartbeat_interval (default: 120 seconds, minimum: 30 seconds) - configurable heartbeat interval for connection keep-alive mechanismlog_level (INFO/DEBUG/WARNING/ERROR, default: INFO) - can be changed online without redeploymentRecommended configuration choices (brief):
azure_openai_structured for stricter schema handling and more reliable structured parsingpgvector with connection_string + psycopg3 pool for stability (TCP keepalive + pool lifecycle)Note: All JSON configuration fields are displayed as password fields (hidden input) in the Dify UI to protect sensitive information. Legacy *_json fields are no longer shown in the UI.
async_mode=true): Recommended for production and batch jobs; returns task_id and runs in background.async_mode=false): Recommended for testing or small runs; sequential and blocking.Details (including batch processing behavior) are in CONFIG.md under Extract Long-Term Memory.
Once configured, all 12 tools are available in your workflows!
๐ For complete usage examples with all 12 tools, see CONFIG.md - Usage Examples
In Dify workflow, add the add_memory tool and configure the following parameters:
Required Parameters:
user: User message (e.g., "I love Italian food")user_id: User identifier (e.g., "alex")Optional Parameters:
assistant: Assistant response (e.g., "Great! I'll remember that.")agent_id: Agent identifier for scopingrun_id: Workflow run ID for tracing (recommended to use Dify's workflow_run_id)metadata: Custom JSON metadata stringIn Dify workflow, add the search_memory tool and configure the following parameters:
Required Parameters:
query: Search query (e.g., "What food does alex like?")user_id: User identifier (e.g., "alex")Optional Parameters:
top_k: Maximum number of results (default: 5)filters: JSON filter string for advanced filteringagent_id: Agent identifier for scopingrun_id: Workflow run ID for tracingKey Points:
user_id is required for add_memory, search_memory, and get_all_memoriesfilters and metadata must be valid JSON strings when providedtop_k defaults to 5 if not specified for search_memoryrun_id (optional): Recommended to use Dify's workflow_run_id for call chain tracking. Note: This parameter is only for tracing and is NOT used as a condition for memory layering or filtering| Tool | Description |
|---|---|
add_memory | Add new memories (user_id required) |
search_memory | Search with filters and top_k, returns timestamp field |
get_all_memories | List all memories |
get_memory | Get specific memory |
update_memory | Update memory content |
delete_memory | Delete single memory |
delete_all_memories | Batch delete memories |
get_memory_history | View change history |
extract_long_term_memory | Extract semantic/episodic/procedural memories from Dify conversation history |
check_extraction_status | Check the status and progress of async extraction tasks |
get_user_checkpoint | Inspect extraction checkpoint state for a user/app |
forget_memories | Forget stale memories and clean old checkpoints (supports dry_run) |
Note: extract_long_term_memory uses conversations_limit as the per-user total conversation cap within the configured days_back time range.
๐ด IMPORTANT: The plugin has undergone breaking changes in credentials configuration that make old and new configurations incompatible. You MUST delete old credentials before upgrading to avoid configuration errors.
Version History:
pgvector_min_connections and pgvector_max_connections credential fields (now configured in vector store JSON)*_json fields completely, only *_secret fields are availablesecret-input type fields (e.g., local_llm_json_secret, local_embedder_json_secret, local_vector_db_json_secret)pgvector_min_connections and pgvector_max_connections as separate credential fieldstext-input type fields (e.g., local_llm_json, local_embedder_json, local_vector_db_json)Why This Causes Issues:
text-input to secret-input typetext-input type will cause Internal Server Error or configuration errors when upgradinglocal_llm_json โ local_llm_json_secret), making them incompatiblepgvector_min_connections and pgvector_max_connections fields will cause configuration errors if still presentโ ๏ธ BEFORE UPGRADING, YOU MUST:
Backup Your Configuration (Optional but Recommended)
Delete Old Credentials
Settings โ Plugins โ mem0aiDelete Credentials or remove all existing credential valuesUpgrade the Plugin
Reconfigure Credentials
Settings โ Plugins โ mem0ai*_secret field names:
local_llm_json_secret (was local_llm_json)local_embedder_json_secret (was local_embedder_json)local_vector_db_json_secret (was local_vector_db_json)local_graph_db_json_secret (was local_graph_db_json, optional)local_reranker_json_secret (was local_reranker_json, optional)pgvector_min_connections and pgvector_max_connections credential fields, you must now configure them in the local_vector_db_json_secret JSON config:
"minconn": 10 and "maxconn": 20 to your pgvector config JSON (or set maxconn to match your max_concurrent_memory_operations, default: 20). See CONFIG.md for examples.โ ๏ธ If You Skip Deleting Old Credentials:
โ ๏ธ Important Configuration Changes:
*_json configuration fields (e.g., local_llm_json, local_embedder_json) are completely removed from the configuration UI*_secret fields (e.g., local_llm_json_secret, local_embedder_json_secret) are available*_secret fieldsNew Features:
run_id parameter for better call chain tracking (recommended to use Dify's workflow_run_id)โ ๏ธ Critical Issue: If you upgrade from v0.1.3 directly to v0.1.6+, you will encounter an Internal Server Error because:
text-input type for credential fields (e.g., local_llm_json)secret-input type with different field names (e.g., local_llm_json_secret)Required Steps:
โ Delete Old Credentials First (MANDATORY)
Settings โ Plugins โ mem0ai โ Delete CredentialsUpgrade the Plugin
Reconfigure Using New Fields
Settings โ Plugins โ mem0ai*_secret fields:
local_llm_json_secret (replaces local_llm_json)local_embedder_json_secret (replaces local_embedder_json)local_vector_db_json_secret (replaces local_vector_db_json)local_graph_db_json_secret (replaces local_graph_db_json, optional)local_reranker_json_secret (replaces local_reranker_json, optional)Note: v0.1.7 provides backward compatibility in code (can read old field names), but the UI only shows new fields. For cleanest upgrade, always delete old credentials and reconfigure.
v0.1.6 Installation Time Issue:
transformers and torch dependencies for local reranker supportv0.1.7 Solution:
transformers and torch from default dependencies to restore fast installation (~22 seconds)# Access the Dify plugin container
docker exec -it <plugin-container-name> /bin/bash
# Install transformers and torch
pip install transformers torch
Note:
cohere>=6.1.0) in the plugin runtime environment๐ For detailed operational notes, runtime behavior, and troubleshooting, see CONFIG.md
Clone the repository
git clone https://github.com/beersoccer/mem0_dify_plugin.git
cd mem0_dify_plugin
Install dependencies
pip install -r requirements.txt
Run locally
python -m main
Run YAML validation:
for file in tools/*.yaml; do
python3 -c "import yaml; yaml.safe_load(open('$file'))" && echo "โ
$(basename $file)"
done
| Version | Date | Changes |
|---|---|---|
| v0.3.1 | 2026-05-16 | Windows psycopg3 connection fix, conditional psycopg platform dependency, write timeout 15โ45 s, Ollama dependency fix |
| v0.3.0 | 2026-04-22 | Checkpoint and distributed lock reliability improvements, async checkpoint test isolation, provider compatibility gate and registry validation |
| v0.2.12 | 2026-04-16 | Dynamic extract_long_term_memory parameter binding via form: llm, bundled Cohere SDK dependency, and reranker documentation refresh |
| v0.2.11 | 2026-04-14 | AsyncMemory.from_config compatibility across mem0 variants, supported mem0 version range alignment, and release/test documentation refresh |
| v0.2.10 | 2026-03-23 | Score semantics unification, memory evolution lifecycle, and new forget_memories maintenance controls |
| v0.2.9 | 2026-03-04 | Extraction worker-pool sliding-window optimization with tighter time-budget and progress flushing behavior |
| v0.2.8 | 2026-02-12 | Stability under load: pre-enqueue overload guard, conservative defaults, pgvector pool/DSN hardening |
| v0.2.7 | 2026-02-08 | Checkpoint windowing, resume cursor accuracy, normalized message timestamps |
| v0.2.6 | 2026-02-07 | Extraction resume safeguards, richer status metrics, local-time task timestamps |
| v0.2.5 | 2026-02-04 | Documentation refresh: recommended config choices and placeholder-safe examples |
| v0.2.4 | 2026-02-03 | Resource isolation optimization: Connection pool sharing for long-term memory tool (67% reduction in database connections) |
| v0.2.3 | 2026-01-31 | Documentation updates: Comprehensive documentation synchronization, merged design documents, improved consistency |
| v0.2.2 | 2026-01-30 | Performance optimizations: Smart memory classification (33% LLM call reduction), token-aware processing with tiktoken, code quality improvements |
| v0.2.1 | 2026-01-29 | Critical bug fix: Data loss prevention when time range expands backward, enhanced checkpoint with time range awareness |
| v0.2.0 | 2026-01-22 | New tool: Long-term memory consolidation, automatic retry mechanism, distributed lock, enhanced checkpoint, atomic save |
| v0.1.9 | 2025-01-11 | Connection stability & resource management: TCP silent timeout prevention, connection pool memory leak prevention, PGVector configuration enhancement |
| v0.1.8 | 2025-12-25 | Dynamic log level configuration, timeout optimization, request tracing with run_id, configuration cleanup |
| v0.1.7 | 2025-12-16 | CPU overload protection, seamless upgrade compatibility, configuration validation, code quality improvements |
| v0.1.6 | 2025-12-08 | Security enhancement (secret-input for all configs), user-configurable performance parameters |
| v0.1.5 | 2025-11-28 | Search memory timestamp support, code refactoring with helpers module |
| v0.1.4 | 2025-11-23 | Logging investigation and documentation update |
| v0.1.3 | 2025-11-22 | Unified logging configuration, database connection pool optimization, pgvector config enhancement, constant naming optimization |
| v0.1.2 | 2025-11-21 | Configurable timeout parameters, optimized default timeouts (30s for all read ops), code quality improvements |
| v0.1.1 | 2025-11-20 | Timeout & service degradation for async operations, robust error handling, resource management improvements, production stability fixes |
| v0.1.0 | 2025-11-19 | Smart memory management, robust error handling for non-existent memories, race condition protection, bug fixes |
| v0.0.9 | 2025-11-17 | Unified return format, enhanced async operations (Update/Delete/Delete_All non-blocking), standardized fields, extended constants, complete documentation |
| v0.0.8 | 2025-11-11 | async_mode credential (default true), sync/async tool routing, provider validation aligned, docs updated |
| v0.0.7 | 2025-11-08 | Self-hosted mode refactor, centralized constants, background event loop with graceful shutdown, non-blocking add (queued), search via background loop, normalized outputs |
| v0.0.4 | 2025-10-29 | Dual-mode (SaaS/Local), unified client, simplified Local JSON config, search top_k, add requires user_id, HTTPโSDK refactor |
| v0.0.3 | 2025-10-06 | Added 6 new tools, v2 API support, metadata, multi-entity |
| v0.0.2 | 2025-02-24 | Basic add and retrieve functionality |
| v0.0.1 | Initial | First release |
See CHANGELOG.md for detailed changes.
Contributions are welcome! Please feel free to submit a Pull Request.
git checkout -b feature/AmazingFeature)git commit -m 'Add some AmazingFeature')git push origin feature/AmazingFeature)This project is licensed under the MIT License - see the LICENSE file for details.
If you find this plugin useful, please give it a โญ on GitHub!
This project is a deeply modified and enhanced version of the excellent dify-plugin-mem0 project by yevanchen.
I sincerely appreciate the foundational work and outstanding contribution of the original author, yevanchen. The project provided a solid foundation for my localized, high-performance, and asynchronous plugin.
Key Differences from the Original Project:
The original project primarily supported Mem0 platform (SaaS mode) and synchronous request handling. This project has been fully refactored to include: