DeepSeek Harness (DSH) is an AI coding assistant framework from DeepSeek that can be extended with plugins. Because the Hologres long memory service (OpenMemory) is compatible with the Mem0 API, you can connect DSH to it through the official Mem0 plugin @mem0/deepseek-plugin and give your AI agent persistent, cross-session memory. This topic describes how to set up the integration.
Prerequisites
-
DeepSeek Harness is installed. We recommend version
v0.1.0-rc.8or later. -
Node.js v18 or later and npm are installed.
-
A long memory service is created in the Hologres console, and you have its endpoint and API key. For more information, see Create and use long memory service.
-
The environment where DSH runs can reach the endpoint of the long memory service. Within the same VPC, we recommend the internal endpoint. Across VPCs or from a local environment, use the public endpoint and add your IP address to the whitelist.
Step 1: Create a DSH profile and install the Mem0 plugin
DSH uses profiles to keep plugin and model configurations separate. The following steps install the Mem0 plugin in a profile named mem0-holo.
-
Create the profile directory and initialize an npm project.
mkdir -p ~/.dsh/profiles/mem0-holo && cd ~/.dsh/profiles/mem0-holo npm init -y -
Install the Mem0 plugin and its dependency.
# @mem0/deepseek-plugin is published only to the public npmjs.org registry, # so specify the registry explicitly. npm install @mem0/deepseek-plugin --registry https://registry.npmjs.org npm install mem0ai --registry https://registry.npmjs.org -
Replace the duplicated
@deepseek-aidependencies in the profile with symbolic links to the main DSH installation, so that only one copy of each dependency exists.# 1. Locate the @deepseek-ai dependency directory in the main DSH installation # and set MAIN to your actual installation path: # Global npm install: $(npm root -g)/@deepseek-ai/dsh/node_modules/@deepseek-ai # Homebrew install: /opt/homebrew/lib/node_modules/@deepseek-ai/dsh/node_modules/@deepseek-ai MAIN="/opt/homebrew/lib/node_modules/@deepseek-ai/dsh/node_modules/@deepseek-ai" # 2. Back up the duplicated packages in the profile and replace them with symbolic links. cd ~/.dsh/profiles/mem0-holo/node_modules/@deepseek-ai for p in "$MAIN"/*/; do name="$(basename "$p")" [ -d "$name" ] && mv "$name" "${name}.bak-$(date +%s)" ln -s "$MAIN/$name" "$name" done
If two copies of the @deepseek-ai dependencies exist, one in the profile and one in the main DSH installation, an internal symbol check fails and DSH reports Cannot read properties of undefined (reading 'prepare') at startup. Running npm install again recreates the duplicates, so you must repeat the symbolic link step.
Step 2: Configure DSH to connect to the Hologres long memory service
The configuration consists of two parts: environment variables and the profile configuration file.
Set environment variables
Run the following commands to set the environment variables:
export MEM0_API_KEY="<YOUR-HOLOGRES-MEM0-API-KEY>"
export DASHSCOPE_API_KEY="<YOUR-DASHSCOPE-API-KEY>"
Parameters:
|
Environment variable |
Description |
|
|
The API key of the Hologres long memory service. The key is prefixed with |
|
|
The API key of Alibaba Cloud Model Studio, used to call the large language model. Skip this variable if you have configured a different LLM provider. |
DSH reads environment variables at startup. Export the variables before you start DSH. If you set them while DSH is running, restart DSH for the change to take effect.
Write the DSH profile configuration file
In the ~/.dsh/profiles/mem0-holo/ directory, create a file named cordis.patch.yml with the following content:
# Model Studio provider configuration. Replace this block if you use a different LLM provider.
- id: llm-pi-ai
config:
providers:
bailian:
apiKeyEnv: DASHSCOPE_API_KEY
api: openai-completions
baseURL: https://dashscope.aliyuncs.com/compatible-mode/v1
compat:
supportsDeveloperRole: false
maxTokensField: max_tokens
models:
- id: deepseek-v3
input: [text]
# Default model
- id: agent-default-model
config:
provider: bailian
model: deepseek-v3
# Official Mem0 plugin. Point host to the Hologres long memory service endpoint.
- insert:
- id: mem0
name: "/absolute/path/to/node_modules/@mem0/deepseek-plugin/dist/index.js"
config:
userId: "<YOUR-USER-ID>"
host: "<YOUR-HOLOGRES-MEM0-ENDPOINT>"
Parameters:
|
Parameter |
Description |
|
|
The absolute path to the entry file of the Mem0 plugin. Replace |
|
|
The user identifier that isolates memory data between users. We recommend a meaningful value, such as your employee ID or username. |
|
|
The endpoint of the Hologres long memory service, including the protocol prefix. For example, |
To use a different LLM provider, modify only the llm-pi-ai and agent-default-model blocks. Leave the mem0 plugin configuration unchanged.
Step 3: Start DSH and verify the connection
Run one of the following commands to start DSH with the mem0-holo profile:
# Command line mode
dsh --profile mem0-holo
# Web UI mode
# Note: --profile is a global option and must precede the subcommand, such as web.
dsh --profile mem0-holo web
After DSH starts, enter the following prompt in the conversation to verify that the plugin is loaded:
Search my memories for anything relevant.
If the plugin is loaded, DSH calls the search_memory tool. The result may be empty the first time you use the service, because no memories exist yet. This is expected.
Step 4: Use the long memory service
After the plugin is loaded, it registers the following tools. DSH calls them automatically during a conversation, so no manual action is required.
|
Tool |
Description |
|
|
Writes information to long-term memory. DSH decides from the conversation whether information is important enough to save. |
|
|
Runs a semantic search over long-term memory. DSH calls this tool to retrieve relevant memories as context when it answers a question. |
Example: Cross-session memory recall
The following example writes a memory in one session and recalls it in a new session.
Write a memory
Tell the agent what to remember:
Remember this: our team uses Hologres as its real-time data warehouse, and our main query pattern is vector retrieval combined with graph aggregation.
The agent calls add_memory to write the information to the long memory service.
Recall across sessions
Start a new session and ask the agent:
Which data warehouse does our team use, and what query patterns have we been using?
The agent calls search_memory to retrieve the stored memory and refers to it in the answer.
Manage memories directly
You can also manage memories with natural language:
|
Operation |
Example prompt |
|
Add a memory |
Remember this: Zhang San owns project X. |
|
Search memories |
Remind me of the Hologres optimization plan we discussed. |
|
Delete memories |
Delete my memories about the old API version. They are out of date. |
FAQ
The search_memory and add_memory tools are not loaded
Check the following items in order:
-
The profile name that you pass at startup matches the profile that you created.
-
cordis.patch.ymlexists in the profile directory, and the file thatnamepoints to exists. -
MEM0_API_KEYis set, and its value is prefixed withom-.
A memory search returns no results
Check the following items in order:
-
The long memory service contains memory data.
-
The current
userIdmatches the one used when the memory was written. Memory data is isolated byuserId. -
The environment where DSH runs can reach the endpoint of the long memory service, and its outbound IP address is in the whitelist.
An error occurs when the Model Studio model is called
Check that DASHSCOPE_API_KEY is valid and that the configured model ID, such as deepseek-v3, is available in Alibaba Cloud Model Studio.
Cannot read properties of undefined (reading 'prepare')
Cause: Two copies of the @deepseek-ai dependencies exist, one in the profile and one in the main DSH installation, which makes an internal symbol check fail.
Solution: Follow Step 1 to replace the duplicated dependencies in the profile with symbolic links to the main installation, and then restart DSH.
search_memory failed: Internal Server Error
Cause: When the model calls the search operation with an empty query, the search operation of the long memory service returns HTTP status code 500.
Solution: Modify the plugin file node_modules/@mem0/deepseek-plugin/dist/index.js so that an empty query is routed to the list operation instead.
-
Find the following line:
query: { type: "string", description: "What to recall.", required: true },Replace it with:
query: { type: "string", description: "What to recall. Optional: if omitted or empty, returns the most recent memories instead of running a semantic search." }, -
Replace the
tryblock of theexecutemethod with the following code:async execute({ query, limit, userId: u, agentId, runId }) { const filters = resolveSearchFilters({ userId: u, agentId, runId }, userId); try { const topK = limit && limit > 0 ? limit : DEFAULT_SEARCH_LIMIT; if (!query || !String(query).trim()) { // For an empty query, call the list operation to return the most recent // memories and avoid the error from the search operation. const listed = await client.getAll({ filters, pageSize: topK }); const results = listed?.results ?? []; return truncateOutput(formatMemoryList(results)); } const { results } = await client.search(query, { filters, topK }); return truncateOutput(formatMemoryList(results ?? [])); } catch (err) { return `search_memory failed: ${err instanceof Error ? err.message : String(err)}`; } } -
Restart DSH to apply the change.
This change applies to the build output of the plugin. Reinstalling or upgrading @mem0/deepseek-plugin overwrites it, and you must apply the change again.
invalid arguments: missing required property 'query'
Cause: The query parameter is required by default, so the framework rejects the call when the model omits it. DSH usually retries automatically, and the error does not normally affect usage.
Solution: This error has the same root cause as search_memory failed: Internal Server Error. Use the same procedure to make query optional.
The --profile option has no effect
--profile is a global option and must precede the subcommand. For example, to start the web UI, run dsh --profile mem0-holo web instead of dsh web --profile mem0-holo.
MEM0_API_KEY has no effect after it is set
DSH reads environment variables at startup. Export the variable before you start DSH. If DSH is already running, restart it.