All Products
Search
Document Center

AnalyticDB:Long-term memory service

Last Updated:Jun 23, 2026

The long-term memory service is a core capability of Context Service. Built on ADBPGMem, it provides memory data management and service configuration for three memory scenarios: Session, User, and Agent.

Log on to the ADBPGMem dashboard

After you activate the long-term memory service, you can manage memory data and configure the service on the ADBPGMem Dashboard.

  1. On the Context Service page, select the target workspace.

  2. In the Long-term Memory service area of the workspace, click Access Service to log on to the ADBPGMem Dashboard.

Core features

Memory scenarios

The service supports the following three memory scenarios:

Memory scenario

Description

Retrieval method

Session

A short-term memory scenario that focuses on memories within a specific conversation session, without referencing other sessions. Memories are persistently stored unless explicitly deleted through the memory deletion API.

Load or retrieve all memories for the session by using the Run ID.

User

References all of a user's historical memories across sessions. Primarily stores factual, episodic, and semantic memory types.

Retrieve all memories for a user by using the User ID, or retrieve memories for a specific session by using both the User ID and Session ID.

Agent

Designed for the long-term memory of an AI agent. Agent memory focuses on procedural memory, such as actions and outcomes of sub-tasks. When your application calls the agent memory API, AnalyticDB for PostgreSQL uses a specific prompt to extract the agent-LLM interaction history and stores it as memory in a vector store.

Retrieve all memories for an agent by using the Agent ID, or retrieve memories for a specific session by using both the Agent ID and Session ID.

Memory categories

For each memory, ADBPGMem automatically classifies the content and supports category-based retrieval. A single memory can have multiple category tags.

Category

Description

personal_details

Static personal information: age, gender, contact details, nationality, educational background, etc.

family

Family relationships: spouse, children, parents, relatives, and dynamic family events.

professional_details

Professional information: job title, company history, industry expertise, skills, career achievements, and goals.

sports

Sports interests: sports participation, preferences (team/individual), training habits, and achievements.

travel

Travel history: places visited, preferred destinations, travel frequency, and accommodation preferences.

food

Dietary preferences: favorite cuisines, allergies/restrictions, cooking habits, and restaurant preferences.

music

Music preferences: genres, favorite artists, instruments played, and concert attendance.

health

Health status: medical records, fitness plans, nutrition plans, and physical/mental wellness goals.

technology

Technology-related: device preferences, software proficiency, programming skills, and interest in new technologies.

hobbies

Interests and hobbies: reading, art, crafts, gardening, gaming, and related community involvement.

fashion

Fashion style: clothing preferences, brand affinities, shopping habits, and accessory choices.

entertainment

Entertainment preferences: movies, TV shows, books, streaming platforms, and theater/festival attendance.

milestones

Life milestones: graduation, wedding, promotions, awards, and significant personal achievements.

user_preferences

User settings and preferences: UI themes, language settings, notification configurations, tool customizations, etc.

misc

Miscellaneous: information that does not fit into other categories, temporary notes, or special records.

Memory retrieval

  1. Query processing

    • Uses an LLM to extract key information from the user's original query.

    • Generates appropriate filtering conditions, such as categories or time ranges, based on context and query intent to improve retrieval efficiency and accuracy.

    • Configurable retrieval parameters: the number of memories to return (TopK) and a retrieval threshold (Threshold). Memories with scores below the threshold are not returned.

  2. Vector search

    • Performs semantic search in a vector database by creating an embedding from the optimized query.

    • Ranks results based on their relevance to the query.

    • Applies specified filters (user, agent, metadata, etc.).

  3. Result processing

    • Integrates results from multiple search criteria and ranks them by relevance, importance, and time.

    • Returns memory entries with their relevance scores.

    • Includes relevant metadata and timestamps, such as tags and categories.

Memory update

  1. Information extraction

    • Uses an LLM to extract relevant memories from the conversation context.

    • Identifies important entities and extracts relationships between them to build a knowledge graph.

  2. Memory storage

    • A vector database stores the actual memory content.

    • A graph database stores the relationships between entities.

    • Memory content is automatically updated in each turn of the conversation.

ADBPGMem benefits

ADBPGMem is compatible with the mem0 protocol and offers capabilities beyond the mem0 community edition:

Feature

ADBPGMem

Mem0 community edition

Memory CRUD operations

Supported

Supported

AI agent integration (procedural memory)

Supported and optimized

Unavailable

AI agent ecosystem

Integrates with Hermes, OpenManus, Supabase, and SAA

None

Vector engine

In-house vector engine from AnalyticDB for PostgreSQL

Requires user integration

Episodic memory

Supported

Not supported

Time-based memory decay

Supported

Not supported

Asynchronous/synchronous modes

Supported, async_mode is optional

Asynchronous only

Memory lifecycle management

Supported

Not supported

Models

Freedom to choose embedding and LLM models

Foreign models + DeepSeek

Data sovereignty

Supports deployment in and outside of China, keeping data within the specified region

Hosted overseas

API reference

Function

API

Description

Add a memory

POST /v3/memories/add/

Extracts facts from a conversation and writes them to the vector store. This operation is asynchronous by default (async_mode=true). Set to false to wait for the result synchronously.

Search memories

POST /v3/memories/search/

Performs a vector-based semantic search for memories. Entity IDs must be passed in the filters object.

Get all memories

POST /v3/memories/

Retrieves a paginated list of memories. Pass the entity ID in the filters object and pagination parameters (page/page_size) as query parameters.

Get a single memory

GET /v1/memories/{memory_id}/

Gets the details of a single memory by ID.

Update a memory

PUT /v1/memories/{memory_id}/

Updates the content of a specified memory. The request body supports either a text or memory field.

Delete a memory

DELETE /v1/memories/{memory_id}/

Deletes a specified memory.

Batch delete

DELETE /v1/memories/

Deletes memories in batches, filtering by user_id, agent_id, or run_id. This operation is irreversible.

History

GET /v1/memories/{memory_id}/history/

Retrieves the modification history for a specified memory. Each item in the returned list includes fields such as old_memory, new_memory, and event.

Health check

GET /v1/ping/

A health check endpoint that verifies service reachability and authentication validity.

For detailed API usage, log on to the ADBPGMem Dashboard and click API Documentation in the left-side navigation pane.

Agent integration

ADBPGMem supports the mem0 SDK protocol. For example, Hermes Agent requires only one line of configuration to use ADBPGMem as its long-term memory backend.

Hermes agent

Hermes uses a plugin architecture for its memory system (MemoryProvider ABC). The official built-in mem0 plugin communicates with the memory backend through the mem0 SDK. Any mem0-compatible service can serve directly as the memory backend for Hermes.

Mem0 SDK compatibility

ADBPGMem implements full compatibility with the mem0 SDK's /v3/ paths on top of its REST API.

Mem0 SDK call

Internal path

Compatibility status

client.search()

POST /v3/memories/search/

Fully compatible

client.add()

POST /v3/memories/add/

Fully compatible

client.get_all()

POST /v3/memories/

Fully compatible

client.delete()

DELETE /v1/memories/{id}

Fully compatible

Key adaptations:

  • Path mapping: Maps /v3/memories/search/ to the internal semantic search engine.

  • Parameter format compatibility: Accepts both a top-level user_id parameter and the nested filters: {user_id: ...} format.

  • Response format alignment: The response structure is consistent with the mem0 Platform API ({results: [...], total, page, ...}).

No adapters or custom HTTP clients are required — any framework that uses MemoryClient(host=...) is plug-and-play, including mem0 ecosystem applications such as Hermes, LangChain, and CrewAI.

image

Hermes mem0 plugin changes

The mem0 plugin in Hermes originally supported only the official Mem0 Platform. To integrate with ADBPGMem, add a base_url configuration option to the plugin:

# plugins/memory/mem0/__init__.py (+9, -1)

# Core change in _get_client():
- self._client = MemoryClient(api_key=self._api_key)
+ kwargs = {"api_key": self._api_key}
+ if self._base_url:
+ kwargs["host"] = self._base_url
+ self._client = MemoryClient(**kwargs)

Configure ~/.hermes/.env:

MEM0_API_KEY=sk-your-adbpgmem-token
MEM0_BASE_URL=https://your-adbpgmem-endpoint

After Hermes starts, ADBPGMem automatically handles memory extraction, storage, and semantic retrieval on the server side.