Use the hermes-tablestore-memory plugin to connect Hermes Agent to Tablestore's Memory Store. This creates a cloud-based, persistent, and semantic memory for your agents that can be shared across sessions and other agents.
Solution overview
The hermes-tablestore-memory plugin connects the MemoryProvider interface of Hermes Agent to Tablestore's Memory Store, providing agents with cloud-based, persistent semantic memory.
Fully managed and maintenance-free: Tablestore is a fully managed service that eliminates the need to build your own databases or manage vector indexes. Billing is based on usage.
Full data control: Memory data is stored in your own Alibaba Cloud account. You can directly view and audit the data from the Tablestore console and manage permissions with Resource Access Management (RAM).
Cross-session and cross-agent sharing: During write operations, a precise Scope (
appId/tenantId/agentId/runId) is used to retain ownership information. During retrieval, the query is automatically expanded toagentId=*andrunId=*, retrieving data across agents and sessions at the tenant level.Structured semantic memory: The plugin automatically extracts structured facts like names, preferences, tech stacks, and decisions from conversations. These facts are stored as vectors to support semantic search and reranking.
Automatic synchronization and prefetching: After each conversation turn,
sync_turn()is automatically called to synchronize data to Tablestore. Before the next conversation turn,queue_prefetch()is automatically called to prefetch relevant memories and inject them into the context.
Prerequisites
You have activated the Tablestore service and created an instance in a region that supports the Memory Store feature.
NoteCurrently, this feature is only available in the China (Beijing) region.
You have installed Hermes Agent. If not, follow the steps in the next section.
Install and configure Hermes Agent
If you have already installed Hermes Agent, skip this section and proceed to install and configure the hermes-tablestore-memory plugin.
Hermes Agent provides a one-click installation script. For more information, see the official Hermes Agent documentation or its GitHub repository. If the one-click installation fails due to network issues, follow the manual installation steps below.
Step 1: Install Hermes Agent
Install Git (using
yumas an example).yum install -y gitDownload and run the Hermes Agent installation script. The
--skip-setupparameter is used to skip the interactive LLM Provider configuration wizard. This is useful for installation in a non-TTY environment, and you can complete the configuration manually later.curl -fsSL https://raw.githubusercontent.com/NousResearch/hermes-agent/main/scripts/install.sh -o /tmp/hermes-install.sh && bash /tmp/hermes-install.sh --skip-setupNoteIf dependencies take too long to install, you can configure an Alibaba Cloud mirror and try again. For more information, see git clone fails or PyPI downloads are slow during installation.
Create a symbolic link for the global command and verify the installation.
ln -sf /root/.hermes/hermes-agent/venv/bin/hermes /usr/local/bin/hermes && hermes --version
Step 2: Configure the LLM provider
This section is for users who are using Hermes Agent for the first time or changing their model provider. It uses the qwen3-max model from Alibaba Cloud Model Studio (Bailian) as an example to explain how to configure Hermes Agent to correctly route requests to Bailian. Hermes Agent uses ~/.hermes/.env to manage sensitive information (secrets) and ~/.hermes/config.yaml to manage general parameters.
You must activate Alibaba Cloud Model Studio (Bailian) and obtain an API Key.
Use
hermes config setto set the Bailian API key and model name.hermes config set DASHSCOPE_API_KEY your-dashscope-api-key hermes config set model qwen3-maxWrite the DashScope Endpoint to
.env. Configurations such as*_BASE_URLmust be placed in.env. They are not read fromconfig.yaml.echo 'DASHSCOPE_BASE_URL=https://dashscope.aliyuncs.com/compatible-mode/v1' >> ~/.hermes/.envVerify that the provider is automatically identified as Alibaba Cloud (DashScope).
hermes status
The expected output includes Model: qwen3-max and Provider: Alibaba Cloud (DashScope).
Hermes Agent automatically identifies the provider based on environment variables in the following order:
The
active_providerinauth.json.If
OPENAI_API_KEYorOPENROUTER_API_KEYis found, the request is routed to OpenRouter.Other Provider-specific keys (such as
DASHSCOPE_API_KEY, which is routed to Alibaba Cloud).
If you have previously configured OPENAI_API_KEY or OPENAI_BASE_URL, first delete them from .env and config.yaml. Otherwise, OpenRouter will be automatically selected instead of Alibaba Cloud Model Studio (Bailian).
Install and configure the hermes-tablestore-memory plugin
Step 1: Install the plugin
Install plugins by using the
hermes plugins installcommand.hermes plugins install --enable https://github.com/aliyun/hermes-tablestore-memoryInstall the Tablestore Python SDK and its dependencies in the Hermes Agent virtual environment.
cd /root/.hermes/hermes-agent source venv/bin/activate uv pip install tablestore==6.4.5 alibabacloud-tablestore20201209 alibabacloud-credentials
Step 2: Configure the Tablestore instance
Log on to the Tablestore console, create an instance in the China (Beijing) region, and take note of the instance name and endpoint.
Write the AccessKey to
~/.hermes/.env.echo 'TABLESTORE_MEMORY_AK=your-accesskey-id' >> ~/.hermes/.env echo 'TABLESTORE_MEMORY_SK=your-accesskey-secret' >> ~/.hermes/.envConfigure the plugin parameters in
~/.hermes/tablestore_memory.json.{ "instance_name": "your-tablestore-instance", "endpoint": "https://your-tablestore-instance.cn-beijing.ots.aliyuncs.com", "memory_store_name": "hermes_mem", "description": "", "app_id": "hermes", "tenant_id": "", "enable_rerank": true, "auto_create_store": true, "timeout": 30.0 }NoteWhen
auto_create_storeis set totrue, the plugin automatically creates a Memory Store namedhermes_memand its corresponding Search Index when it connects to a Tablestore instance for the first time. No manual operation is required.Activate
tablestore-memas the memory Provider.hermes config set memory.provider tablestore-mem
Step 3: Verify the installation
Run the plugin's diagnostic command to check its initialization status.
hermes tablestore-mem doctorThe expected JSON output is as follows. Key fields include
ok: true,provider: tablestore-mem,instance_name,endpoint, andmemory_store_name: hermes_mem. In addition, thechecksobject contains theinitialize,describe_memory_store, andlist_memoriesfields, all of which are set took: true.{ "ok": true, "provider": "tablestore-mem", "instance_name": "your-tablestore-instance", "endpoint": "https://your-tablestore-instance.cn-beijing.ots.aliyuncs.com", "memory_store_name": "hermes_mem", "checks": { "initialize": {"ok": true}, "describe_memory_store": {"ok": true}, "list_memories": {"ok": true} } }Write a test memory synchronously and verify the semantic search.
hermes tablestore-mem add --sync "The user prefers concise replies in Chinese" hermes tablestore-mem search "response style"add --syncforces the operation to wait for vectorization and indexing to complete. Without--sync, the write operation is performed asynchronously, and recently written memories may not be retrievable for a short period.
Using the memory
CLI commands
The hermes tablestore-mem subcommand provides command-line operations for the Memory Store. The following are common commands.
Command | Description |
| Write a memory. |
| Performs a semantic search for memories and returns them sorted by relevance. |
| Performs a read-only diagnostic to verify the connection, Memory Store status, and total memory count. |
Agent tools
After tablestore-mem is activated, Hermes Agent can autonomously call the following four tools to manage memory during the interaction process.
Tool name | Description |
| Lists a snapshot of memories stored in the current scope. |
| Searches the Tablestore long-term memory and returns sorted results. |
| Persistently saves a fact or short text to Tablestore. |
| Deletes a specific Tablestore memory by its ID. |
After each round of conversation, the plugin automatically calls sync_turn() to synchronize key conversation points to Tablestore. Before the next round of conversation, it automatically calls queue_prefetch() to prefetch relevant memories and inject them into the context. You do not need to manually trigger these actions.
FAQ
Plugin initialization error with 'ListMemoryStores'
The Tablestore Memory Store feature is new and only available in select regions. If you have created an instance in an unsupported region, you must create a new instance in a supported region.
Empty search results after writing
The hermes tablestore-mem add command runs asynchronously by default and returns a status of running. Vectorization and index creation take several to more than ten seconds. To verify the result of the write operation, add the --sync parameter to wait for the process to complete. Similarly, when the Agent automatically calls tablestore_remember, the operation is also asynchronous by default, and search results become consistently available after a delay of a few seconds.
Git clone failures and slow PyPI downloads
Direct connections to GitHub and PyPI can be unstable in some network environments. We recommend configuring an Alibaba Cloud PyPI mirror to accelerate uv package downloads.
mkdir -p ~/.config/uv
cat > ~/.config/uv/uv.toml <<'EOF'
[[index]]
url = "https://mirrors.aliyun.com/pypi/simple/"
default = true
EOFBecause pyproject.toml is configured with exclude-newer = "7 days" and the Alibaba Cloud PyPI mirror is missing upload-date metadata, uv treats packages without a date as newer than the cutoff, which causes a resolution failure.
Modify
pyproject.tomland comment out theexclude-newersetting.sed -i 's/^exclude-newer = "7 days"/# exclude-newer = removed/' /usr/local/lib/hermes-agent/pyproject.toml rm -f /usr/local/lib/hermes-agent/uv.lockManually install dependencies within the Hermes virtual environment.
cd /usr/local/lib/hermes-agent source venv/bin/activate export VIRTUAL_ENV=/usr/local/lib/hermes-agent/venv export PATH="$HOME/.local/bin:$PATH" uv pip install -e '.[all]'After installation, create a symbolic link for the global command.
ln -sf /root/.hermes/hermes-agent/venv/bin/hermes /usr/local/bin/hermes && hermes --version
LLM requests are routed to OpenRouter
Hermes Agent automatically identifies the provider by using environment variables, and OPENAI_API_KEY and OPENROUTER_API_KEY have a higher priority than keys for other providers. If requests are routed to OpenRouter, check ~/.hermes/.env and ~/.hermes/config.yaml, and remove any remaining OPENAI_API_KEY and OPENAI_BASE_URL configurations.