Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 18 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,24 @@

---

## Version 0.2.12 (2026-04-16)

### ✨ Enhancements
- **Dynamic extraction tool parameters**:
- Switched all `extract_long_term_memory` tool inputs to `form: llm` so Dify workflows can bind system variables and upstream node outputs more consistently
- **Bundled Cohere SDK support**:
- Added `cohere>=6.1.0` to runtime dependencies so Cohere reranker setups work without extra manual installation

### 🛠️ Reliability & Compatibility
- **Older Dify editor compatibility**:
- Reduced schema differences between extraction and other memory tools, improving variable-binding behavior on older Dify releases that handle `form: form` less reliably

### 🔧 Configuration / Defaults
- **Documentation refresh for reranker setup**:
- Updated README and CONFIG guidance to clarify that cloud rerankers may require provider-specific SDKs, with Cohere documented explicitly

---

## Version 0.2.11 (2026-04-14)

### ✨ Enhancements
Expand Down
9 changes: 5 additions & 4 deletions CONFIG.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# Mem0 Dify Plugin - Configuration Guide

Last updated: 2026-04-14
Last updated: 2026-04-16

This guide provides detailed installation and configuration instructions for the Mem0 Dify Plugin.

Expand Down Expand Up @@ -40,7 +40,7 @@ This guide provides detailed installation and configuration instructions for the

**Option B: Install from Package**
1. Click `Upload Plugin` button
2. Select the `.difypkg` file (e.g., `mem0ai-0.2.11.difypkg`)
2. Select the `.difypkg` file (e.g., `mem0ai-0.2.12.difypkg`)
3. Wait for upload and installation to complete

### Step 3: Verify Installation
Expand Down Expand Up @@ -463,7 +463,8 @@ If you have a pre-configured psycopg3 ConnectionPool object, you can pass it dir
**Note**:
- HuggingFace models are automatically cached locally after first download
- This only affects users who want to use **local reranker models**
- If you use **cloud-based rerankers** (e.g., Cohere API), no additional installation is needed
- If you use **Cohere reranker**, install the Cohere SDK dependency (`cohere>=6.1.0`) in the plugin runtime environment
- Other cloud-based rerankers may also require their own provider SDKs depending on the selected backend

**Option 3: Sentence Transformer Reranker (Local model, requires sentence-transformers library)**

Expand Down Expand Up @@ -1159,7 +1160,7 @@ For detailed upgrade instructions and field mapping, see [README.md - Upgrade Gu

**Problem**: Async validation fails with `object AsyncMemory can't be used in 'await' expression`
- **Solution**:
- Upgrade to plugin `v0.2.11` or later, which normalizes old/new `AsyncMemory.from_config()` behavior
- Upgrade to plugin `v0.2.12` or later, which includes the latest compatibility and workflow-configuration improvements
- Keep `mem0ai` within the documented support range: `>=1.0.2,<=1.0.11`
- If your Dify environment is offline, ensure the selected `mem0ai` version is available in the daemon cache or installation mirror

Expand Down
4 changes: 2 additions & 2 deletions PRIVACY.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
## Privacy Policy

Last updated: 2026-04-14
Last updated: 2026-04-16

This privacy policy describes how the Mem0 Dify Plugin handles your information when you use it in **self-hosted mode**.

Expand Down Expand Up @@ -89,4 +89,4 @@ We may update this privacy policy from time to time. Changes will be reflected i
If you have questions about this privacy policy or the plugin, please contact:
- Email: beersocccer@gmail.com

Last updated: 2026-04-14
Last updated: 2026-04-16
10 changes: 5 additions & 5 deletions PR_TEMPLATE.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# Plugin Submission Form

Last updated: 2026-04-14
Last updated: 2026-04-16

## 1. Metadata

Expand Down Expand Up @@ -31,13 +31,13 @@ Please provide the following metadata of your plugin to make it easier for the r

<!-- Please briefly describe the purpose of the new plugin or the updates made to the existing plugin -->

This submission updates the Mem0 Dify plugin to **v0.2.11** (self-hosted mode). Key changes are summarized below; detailed release notes and historical context are in [CHANGELOG.md](https://github.com/beersoccer/mem0_dify_plugin/blob/main/CHANGELOG.md).
This submission updates the Mem0 Dify plugin to **v0.2.12** (self-hosted mode). Key changes are summarized below; detailed release notes and historical context are in [CHANGELOG.md](https://github.com/beersoccer/mem0_dify_plugin/blob/main/CHANGELOG.md).

### Key Updates

- **AsyncMemory Compatibility Fix**: Added a compatibility layer for old/new `AsyncMemory.from_config()` semantics so `async_mode=true` no longer fails on newer mem0 releases
- **Supported Mem0 Version Range**: Aligned dependency declarations and documentation to support `mem0ai>=1.0.2,<=1.0.11`
- **Regression Tests & Release Docs**: Added targeted compatibility/validation tests and refreshed configuration, changelog, privacy, and submission documents for this release
- **Dynamic Extraction Parameters**: Switched `extract_long_term_memory` inputs to `form: llm` so Dify workflows can bind system and upstream variables more reliably
- **Cohere SDK Dependency**: Bundled `cohere>=6.1.0` by default to reduce manual setup for Cohere reranker users
- **Documentation Refresh**: Updated README, CONFIG, changelog, and related release docs to reflect the new extraction parameter behavior and reranker setup guidance

All API keys and credentials are stored locally in the user's Dify instance configuration and are not shared with any third parties. The plugin only communicates with services configured by the user (their LLM, embedding, and database services).

Expand Down
30 changes: 14 additions & 16 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
# Mem0 Dify Plugin v0.2.11
# Mem0 Dify Plugin v0.2.12

[![License: MIT](https://img.shields.io/badge/License-MIT-yellow.svg)](https://opensource.org/licenses/MIT)
[![Dify Plugin](https://img.shields.io/badge/Dify-Plugin-blue)](https://dify.ai)
[![Mem0 AI](https://img.shields.io/badge/Mem0-AI-green)](https://mem0.ai)

Last updated: 2026-04-14
Last updated: 2026-04-16

A comprehensive Dify plugin that integrates [Mem0 AI](https://mem0.ai)'s intelligent memory layer, providing **self-hosted mode** tools with a unified client for self-hosted setups. [View on GitHub](https://github.com/beersoccer/mem0_dify_plugin)

Expand Down Expand Up @@ -37,7 +37,15 @@ A comprehensive Dify plugin that integrates [Mem0 AI](https://mem0.ai)'s intelli
- 🌍 **Internationalized** - Chinese/English
- ⚙️ **Async Mode Switch** - `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.

### What's New (v0.2.11) - AsyncMemory Compatibility & Release Docs ✅
### What's New (v0.2.12) - Dynamic Extract Params & Cohere SDK ✅
- **Dynamic extraction tool inputs**:
- Changed all `extract_long_term_memory` parameters to `form: llm` so Dify can bind system variables and upstream values more consistently
- **Built-in Cohere reranker dependency**:
- Added the `cohere>=6.1.0` runtime dependency and clarified SDK expectations for cloud rerankers in the docs

These changes improve extraction workflow configurability in Dify while reducing manual setup for Cohere reranker users.

### Previous Updates (v0.2.11) - AsyncMemory Compatibility & Release Docs ✅
- **AsyncMemory initialization compatibility**:
- Added a compatibility shim around `AsyncMemory.from_config(...)` so async mode now works whether mem0 exposes it as a coroutine-returning API or a regular classmethod
- Preserved the existing async credential validation flow in the provider, avoiding behavioral changes outside the initialization fix
Expand Down Expand Up @@ -73,18 +81,6 @@ These changes improve cross-backend retrieval consistency and establish a contro

These changes **improve extraction throughput and resource utilization** for large user batches; the global concurrency ceiling across multiple concurrent extraction tasks remains unchanged.

### Previous Updates (v0.2.8) - Stability & Latency Safeguards ✅
- **Pre-enqueue overload guard**: Async operations reject early when pending tasks exceed threshold
- **Conservative defaults for production**: Read timeout 5s, write timeout 15s, aligned concurrency and pgvector pool sizing
- **PGVector connection reliability**: Hardened connection string encoding; `pool_max_waiting` defaults match overload controls

### Previous Updates (v0.2.7) - Checkpoint Windowing & Resume Accuracy ✅
- **Windowed checkpoint scanning**: Incremental scans process only conversations within `[start_time, run_at]`
- **Stronger resume guarantees**: Resume cursors set only when more pages exist
- **Consistent checkpoint updates**: Normalized `created_at` values reduce reprocessing on empty/filtered conversations

### Previous Updates (v0.2.6) - Extraction Status & Resume Refinements! 🛠️

For full historical details, see [CHANGELOG.md](https://github.com/beersoccer/mem0_dify_plugin/blob/main/CHANGELOG.md).

---
Expand Down Expand Up @@ -329,7 +325,8 @@ pip install transformers torch

**Note**:
- This only affects users who want to use **local reranker models**
- If you use **cloud-based rerankers** (e.g., Cohere API, OpenAI), no additional installation is needed
- For **Cohere reranker**, install the Cohere SDK dependency (`cohere>=6.1.0`) in the plugin runtime environment
- Other cloud rerankers may also require their own provider SDKs depending on the selected backend
- Most users do not need local rerankers, so this change benefits the majority of users

---
Expand Down Expand Up @@ -382,6 +379,7 @@ done

| Version | Date | Changes |
|---------|------|---------|
| 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 |
Expand Down
2 changes: 1 addition & 1 deletion manifest.yaml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
version: 0.2.11
version: 0.2.12
type: plugin
author: beersoccer
name: mem0ai
Expand Down
2 changes: 1 addition & 1 deletion performance/README.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# Performance Testing

Last updated: 2026-04-14
Last updated: 2026-04-16

This directory contains performance and load testing scripts for the Mem0 Dify plugin.

Expand Down
3 changes: 2 additions & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[project]
name = "mem0-dify-plugin"
version = "0.2.11"
version = "0.2.12"
description = "Mem0 Dify plugin"
requires-python = ">=3.12"
dependencies = [
Expand All @@ -12,6 +12,7 @@ dependencies = [
"psycopg[binary,pool]",
"dify_plugin",
"tiktoken",
"cohere>=6.1.0",
]

[dependency-groups]
Expand Down
1 change: 1 addition & 0 deletions requirements.txt
Original file line number Diff line number Diff line change
Expand Up @@ -6,3 +6,4 @@ rank-bm25
psycopg[binary,pool] # psycopg3 with connection pool support
dify_plugin
tiktoken # Accurate token counting for conversation processing
cohere>=6.1.0
2 changes: 1 addition & 1 deletion tests/TESTING_COVERAGE.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# 测试覆盖现状(可用于评审与新人理解)

Last updated: 2026-04-14
Last updated: 2026-04-16

## 如何阅读本文件

Expand Down
2 changes: 1 addition & 1 deletion tests/TESTING_README.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# 测试运行说明(零背景可上手)

Last updated: 2026-04-14
Last updated: 2026-04-16

## 这份文档能帮你做什么

Expand Down
2 changes: 1 addition & 1 deletion tests/TESTING_TECHNICAL_GUIDE.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# 测试技术说明(实现机制与排障路径)

Last updated: 2026-04-14
Last updated: 2026-04-16

## 文档定位

Expand Down
18 changes: 9 additions & 9 deletions tools/extract_long_term_memory.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ parameters:
en_US: Required. User IDs to process. Provide a JSON array string (recommended) or comma-separated list.
zh_Hans: 必填。需要处理的 user_id 列表。建议传 JSON 数组字符串,或用英文逗号分隔。
llm_description: Required list of user_ids (JSON array string recommended).
form: form
form: llm
- name: app_id
type: string
required: true
Expand All @@ -47,7 +47,7 @@ parameters:
en_US: Required. Dify App ID for memory isolation. Each app maintains separate memory space for the same user.
zh_Hans: 必填。Dify 应用 ID,用于记忆隔离。同一用户在不同应用中的记忆相互隔离。
llm_description: Required Dify App ID to ensure app-level memory isolation.
form: form
form: llm
- name: run_id
type: string
required: false
Expand All @@ -58,7 +58,7 @@ parameters:
en_US: "Optional unique identifier for tracking the entire memory operation call chain. Recommended to use Dify's workflow_run_id to link multiple memory operations in the same workflow. Note: This parameter is only for tracing the call chain and is NOT used as a condition for memory layering or filtering."
zh_Hans: 可选的唯一标识符,用于追踪整个记忆操作调用链。推荐使用 Dify 的 workflow_run_id 来关联同一工作流中的多个记忆操作。注意:此参数仅用于追踪调用链,不作为记忆分层或过滤的条件。
llm_description: "Optional unique identifier for tracking the entire memory operation call chain. Recommended to use Dify's workflow_run_id to link multiple memory operations in the same workflow. This parameter is only for tracing and is NOT used as a condition for memory layering or filtering."
form: form
form: llm
- name: days_back
type: number
required: false
Expand All @@ -70,7 +70,7 @@ parameters:
en_US: "Optional. Number of days to look back for extracting conversation history (1-7, default 1). For example, days_back=2 extracts yesterday and the day before yesterday."
zh_Hans: "可选。回溯天数,抽取前几天的用户会话历史(1-7,默认1天)。例如 days_back=2 表示抽取昨天和前天的数据。"
llm_description: Number of days to look back for extracting conversation history (1-7, default 1).
form: form
form: llm
- name: conversations_limit
type: number
required: false
Expand All @@ -82,7 +82,7 @@ parameters:
en_US: "Optional. Maximum conversations to process per user per execution (10-500, default: 20). This limit applies to the total conversations within the configured days_back time range. This prevents malicious users from generating excessive conversations and consuming too much processing time. For 1-day cycle: light users ~5, normal users ~10-15, heavy users ~20-30. Adjust based on your execution cycle."
zh_Hans: "可选。每次执行每个用户最多处理的会话数(10-500,默认:20)。该上限适用于当前 days_back 回溯时间范围内的会话总数。防止恶意用户生成过多会话占用处理时间。1天周期下:轻度用户约5个,正常用户约10-15个,重度用户约20-30个。根据执行周期调整。"
llm_description: "Optional. Maximum conversations to process per user per execution (10-500, default: 20). This limit applies to the total conversations within the days_back time range."
form: form
form: llm
- name: max_tokens_per_conversation
type: number
required: false
Expand All @@ -94,7 +94,7 @@ parameters:
en_US: "Optional. Maximum tokens per conversation for memory extraction in thousands (1-200, default: 64K, same as EXTRACTION_DEFAULT_MAX_TOKENS). Token limiting is applied during data fetching to optimize network transfer. If a conversation exceeds this limit, pagination stops early and only the most recent messages are fetched. Adjust based on your LLM's context window (e.g., GPT-4: 128K, Claude 3.5: 200K)."
zh_Hans: "可选。每个会话用于记忆抽取的最大Token数(单位:千,1-200,默认:64K,与 EXTRACTION_DEFAULT_MAX_TOKENS 相同)。Token限制在数据获取阶段应用以优化网络传输。如果会话超过此限制,分页提前停止,只获取最近的消息。根据您的LLM上下文窗口调整(例如 GPT-4:128K,Claude 3.5:200K)。"
llm_description: "Optional. Maximum tokens per conversation for memory extraction in thousands (1-200, default: 64K, same as EXTRACTION_DEFAULT_MAX_TOKENS). Token limiting is applied during Dify API pagination to avoid fetching unnecessary historical messages. Uses tiktoken (EXTRACTION_DEFAULT_ENCODING = cl100k_base) for accurate token counting. Adjust based on your LLM's context window."
form: form
form: llm
- name: time_budget
type: number
required: false
Expand All @@ -106,7 +106,7 @@ parameters:
en_US: "Optional. Maximum time budget in minutes for the extraction task (suggested: 5-120 minutes, default: 60 minutes, same as EXTRACTION_TIME_BUDGET). The lock TTL is automatically calculated as 1.2 times the time budget (rounded up). No upper limit enforced - adjust based on your batch size and processing requirements. For large batch jobs processing 1000+ users, consider increasing this value."
zh_Hans: "可选。提取任务的最大时间预算(单位:分钟,建议:5-120 分钟,默认:60 分钟,与 EXTRACTION_TIME_BUDGET 相同)。锁的 TTL 会自动计算为时间预算的 1.2 倍(向上取整)。不设上限,根据您的批次大小和处理需求调整。对于处理 1000+ 用户的大批量作业,考虑增加此值。"
llm_description: "Optional. Maximum time budget in minutes for the extraction task (suggested: 5-120 minutes, default: 60 minutes, same as EXTRACTION_TIME_BUDGET). The lock TTL is automatically calculated as 1.2 times the time budget (rounded up). No upper limit enforced - adjust based on your batch size and processing requirements."
form: form
form: llm
- name: dify_base_url
type: string
required: true
Expand All @@ -117,7 +117,7 @@ parameters:
en_US: "Required. Standard format: http://dify.t3.test.noahgrouptest.com/v1"
zh_Hans: "必填。标准格式:http://dify.t3.test.noahgrouptest.com/v1"
llm_description: Required Dify base URL for API calls.
form: form
form: llm
- name: dify_api_key
type: string
required: true
Expand All @@ -138,7 +138,7 @@ parameters:
Required Dify API key for API calls. Each Dify App should pass its own key,
preferably via app-level secret variables (e.g. {{secrets.DIFY_API_KEY}}),
not hard-coded in the workflow.
form: form
form: llm
extra:
python:
source: tools/extract_long_term_memory.py
Expand Down
Loading
Loading