All Products
Search
Document Center

AgentLoop:Use a memory store

Last Updated:Sep 15, 2026

Create an AgentLoop memory store, integrate it with your application, write conversations to the store, and retrieve long-term memory for later requests. A cooking assistant example at the end of this topic shows how to use the retrieved memories in later interactions. To validate your first integration, complete three checks in order: the conversation write request succeeds, the relevant long-term memories can be retrieved, and the application adds the retrieval results to the agent request.

Prerequisites

For the basic concepts of memory stores, see Memory Store overview.

  • An existing agent space, and access to the AgentLoop console of that space.

  • The application to integrate, and a set of sample conversations for validation.

  • If you plan to write data through the API, your local machine or the application runtime environment can reach the endpoint provided by the console. The HTTP examples in this topic use curl.

Step 1: Create a memory store

  1. Log on to the AgentLoop console and select the target region and the agent space.

  2. In the left-side navigation pane, choose Context Engineering, and then click the Memory Store tab.

  3. Click Create Memory Store

    Parameter

    Required

    Description

    Memory Store Name

    Yes

    A name that is easy to identify, for example, cooking_memory.

    Memory Store Description

    No

    The purpose of the memory store and the applications that use it, for example, "Stores the dietary preferences of cooking assistant users".

  4. Click OK.

    After the memory store is created, verify the name and the description on the Overview tab to confirm that the subsequent operations target the intended memory store.

Step 2: Create an API key

  1. Go to the details page of the memory store that you created in Step 1, and then click the API Key tab.

  2. If no API key exists, click Create Now and follow the instructions on the page to create an API key.

  3. Copy the API key for application integration.

    An API key is bound to the memory store and the agent space. When you call the memory APIs listed on the API Key tab, you do not need to pass the memory store name or the space name separately.

Distinguish between the following two types of information when you use the memory store:

Information

Purpose

Recommendation

API key

Authenticates the requests that access the corresponding memory store.

Store the API key in server-side environment variables or in the secret management mechanism of your application. Do not commit it to a code repository or expose it in a browser front end.

User identifier

Associates memories with a business user and limits the retrieval scope.

Your application determines the identifier based on the logged-on user. Keep the identifier consistent between writes and retrieval.

Note

user_id is a business data identifier. Your application must still determine the queryable scope based on its own user identity and permissions.

Step 3: Integrate the application and write a conversation

Important

A new memory store requires resource provisioning. Before the first write, allow the preparation time indicated on the Integration tab.

Select an integration method

Go to the Integration tab and select one of the following methods. This topic uses the HTTP API path.

Method

Use case

Entry point on the Integration tab

HTTP API

You want to validate the integration from the command line first, or send HTTP requests from another language.

Select HTTP API, and then copy the access configuration and the request example.

Python SDK

You want to use the mem0-compatible interface in a Python application.

Select Python SDK, and then integrate by following the installation and invocation examples.

Use the copy buttons on the Integration tab to get the configuration of the target memory store. The endpoint must correspond to the selected region, and the API key must come from the current memory store.

Configure access parameters

Replace the placeholders with the actual values from the console:

export AGENTLOOP_ENDPOINT="<Endpoint copied from the Integration tab>"
export AGENTLOOP_API_KEY="<API key of this memory store>"

Write a conversation

The following request uses the same API and the same parameter structure as the HTTP example on the Integration tab, and associates a conversation with the business user user-001:

curl -X POST "$AGENTLOOP_ENDPOINT/v1/memories" \
  -H "Authorization: Token $AGENTLOOP_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "messages": [
      {"role": "user", "content": "I live in Hangzhou and I like unsweetened Americano coffee."},
      {"role": "assistant", "content": "OK. I have noted that you live in Hangzhou and like unsweetened Americano."}
    ],
    "user_id": "user-001",
    "infer": true
  }'

Parameter

Description

messages

The list of conversation messages to write. Each message uses role for the role and content for the text content.

user_id

The business user identifier associated with the conversation. Use the same identifier when you retrieve the memories of this user.

infer

Set to true in this example to request memory extraction from the conversation.

Check the HTTP response to confirm that the request succeeded. This is the first of the three integration checks. If the request failed, check the endpoint, the API key, and the request content based on the response.

Memory extraction needs processing time. After a successful write, continue with the retrieval in Step 4 to confirm that the relevant long-term memories are available. For the rules that apply to the results of each stage, see Interpret validation results.

Use stable business user identifiers

When you integrate the application, reuse the same user_id for one user across sessions, and use a separate identifier for each user.

Step 4: Retrieve long-term memory

  1. On the details page of the memory store, click the Long-term Memory Retrieval tab.

  2. Enter a query statement, for example, "What coffee does this user like?".

  3. Set User ID to user-001

    Parameter

    Description

    topK

    The maximum number of memories to return, for example, 5. The actual number of returned memories may be lower.

    User ID

    Filters the memories by the associated business user identifier. To query the preferences of a user across sessions, retrieve by user scope.

    App ID

    Filters the memories by the associated app identifier.

    Agent ID

    Filters the memories by the associated agent identifier.

    Run ID

    Filters the memories by the associated run identifier. Add this condition only when you need the memories of a specific run. Otherwise, relevant memories from other sessions are excluded.

  4. Click Start Retrieval and view the memory content in the Retrieval Results section.

    A query statement expresses the information that you need, for example, "the dietary preferences of the user" or "what coffee the user likes". The ID filters limit the query scope. Use the two together, and make sure that the App ID, Agent ID, and Run ID filters correspond to the identifiers associated with the data that was actually written.

For the example in this topic, check whether information about "unsweetened Americano coffee" is returned in the Retrieval Results section. This is the second of the three integration checks. To retrieve memories from your application instead of the console, use the API call examples on the Integration tab.

How the application uses memories

After the application is integrated with the memory store, each round of interaction follows this process:

  1. Receive a new question: Determine the user identifier from the logged-on user or the business context of the application.

  2. Retrieve memories: Query the relevant memories by the current question and the user identifier. Use the examples on the Integration tab for the actual API calls.

  3. Organize the model input: Add the relevant memories as background information to the request, together with the current question and the necessary recent conversation.

  4. Generate the answer: The agent answers the question based on the current requirements and the historical background.

  5. Write this conversation: Write the interactions that actually happened in this round to the memory store for later extraction and retrieval.

    The application should keep the explicit requirements of the current question. For example, if the historical memory is "likes coffee" but the user now asks to "recommend beverages without coffee", pass the current requirement to the agent as well. When the retrieval result is empty, the application can continue with the current question and the existing conversation context.

Example: Add user preferences for a cooking assistant

The following example shows how an application uses memories. It does not depend on a specific agent framework.

Stage

Action

What to check

Write the preference

Use the HTTP request structure in Step 3, replace the message content with "I like light, mildly seasoned home-style dishes", and keep user-001.

The request succeeds and the user identifier is correct.

Validate the extraction

Query "the dietary preferences of the user" in the console and set User ID to user-001.

The retrieval results contain information about light, mildly seasoned dishes.

Ask in a new session

The same user asks "What should I have for dinner tonight?" in a new session.

The application keeps retrieving the relevant memories with the same user identifier.

Organize the answer

Provide the relevant preferences to the agent together with the new question.

The application adds the retrieval results to the request, and the answer refers to the relevant preferences. This is the third of the three integration checks.

Organize the model input in the following structure. The memory content must come from the actual retrieval results:

Current question:
What should I have for dinner tonight?
Relevant user memories (background information):
The user prefers light, mildly seasoned home-style dishes.
Response requirements:
Give a suggestion based on the current question and the relevant preferences. The explicit requirements that the user states in this request take precedence.

This is an example of context organization. The actual answer depends on the current question, the retrieval results, and the model. When you validate, first confirm that the memories are retrieved, and then confirm that the application uses them.

Interpret validation results

The checks in Step 3, Step 4, and the cooking assistant example cover different stages of the integration. Use the following rules when you interpret the results:

  • Separate stages — Resource provisioning, conversation writes, and memory extraction are separate stages. Check the write response and the retrieval results individually.

  • Write success — A successful write response, or the word "noted" in the conversation, does not confirm that a memory was extracted.

  • Extracted text — The actual extracted text, language, and number of entries may differ from the input. Judge whether the meaning matches the input.

  • Retrieval score — The score indicates the confidence level of the retrieval match and helps you judge how well a result matches the current question. A score does not mean that the memory content has been fact-checked, and it does not mean that the application must pass all returned results to the agent.

  • Single answer — Do not infer that the entire integration is correct from a single answer.

FAQ

Why can I not write to a memory store immediately after I create it?

New resources need provisioning time. Wait as indicated on the Integration tab before the first write, and then check the response of the write request. After the resources are ready, still validate the conversation write and the long-term memory retrieval.

A write succeeded but no retrieval results are returned. What should I check?

Check the following items in order:

  1. Whether the memory store in the current console corresponds to the API key used in the write request.

  2. Whether the user_id used for the write is the same as the User ID used for the retrieval.

  3. Whether additional conditions such as App ID, Agent ID, and Run ID exclude the target data. For details about these filters, see Step 4: Retrieve long-term memory.

  4. Whether the query statement is related to the input content. You can first validate with an explicit question such as "the coffee preferences of the user".

  5. Whether the conversation is still being processed. Retry the retrieval later.

    The absence of results alone does not mean that the data is lost. When you troubleshoot, judge based on the write response, the query conditions, and the subsequent retrieval results.

Does an agent automatically remember users after I create a memory store?

The application must integrate conversation writes and memory retrieval, and add the relevant results to the model request. Creating a memory store and an API key in the console only prepares the integration.

Do I need to put the entire conversation history into every model request?

The application can combine the relevant long-term memories with the necessary recent conversation based on the current task. Long-term memory supplies reusable background information. Specific references and temporary requirements in the current question still need the current conversation context.

Does the mem0-compatible interface support all methods of other memory SDKs?

Follow the Integration tab of the current memory store, use the methods, parameters, and endpoint provided there, and validate each operation that your application needs. A mem0-compatible interface does not mean that every SDK version and all extended methods are supported.