All Products
Search
Document Center

AnalyticDB:AnalyticDB for MySQL + ReMe Best Practices

Last Updated:Mar 11, 2026

ReMe is a memory management framework for AI Agents that divides an Agent's memory system into three modules: Personal Memory, Task Memory, and Tool Memory. This design allows Agents to intelligently extract, reuse, and share memories during interactions with users and tasks. This tutorial demonstrates AI Agent memory management practices using ReMe and AnalyticDB for MySQL. It covers environment setup, service startup, and provides detailed demos for the three core memory modules.

Prerequisites

Before you begin, ensure that the following prerequisites are met:

  • Create an AnalyticDB for MySQL cluster, and ensure its version supports vector retrieval (such as cosine similarity). For more information, see Quick Start for Enterprise, Basic, and Data Lakehouse Editions.

  • Obtain the ReMe framework version that supports AnalyticDB for MySQL.

    Note

    Contact Alibaba Cloud Service Support via DingTalk (DingTalk account: x5v_rm8wqzuqf) to get the installation package.

  • Obtain a model service API key. This tutorial uses Alibaba Cloud Model Studio. Activate the service and get an API key. For more information, see Get an API Key.

User Guide

Environment Setup

  • Prepare AnalyticDB for MySQL.

    1. Create a database for this tutorial in your AnalyticDB for MySQL cluster.

      CREATE DATABASE reme;
    2. If you plan to connect via the public network, enable public network access for the cluster in the AnalyticDB for MySQL console, and add the public IP address of your demo environment to the whitelist.

  • Install ReMe and its dependencies.

    1. Check your Python environment: Ensure Python is installed in your environment. This tutorial is validated with Python 3.12.2.

      # For Mac, check Python version. If not installed, install from https://www.python.org/
      python3 --version
      
      # For Linux, check Python version. If not installed, install using yum: sudo yum install python
      python --version
    2. Install the ReMe framework. Unzip the Mem0 framework files and install the required dependency libraries.

      # Unzip and install flowllm
      unzip flowllm.zip
      cd flowllm
      pip install .
      
      # Unzip and install ReMe
      unzip ReMe.zip
      cd Reme
      pip install .

Configure and Start

  • Configure environment variables:

    For security, configure the Large Language Model (LLM) API key as an environment variable.

    echo "export DASHSCOPE_API_KEY='<YOUR_DASHSCOPE_API_KEY>'" >> ~/.bashrc
    # Optional; defaults to Singapore
    echo "export DASHSCOPE_BASE_URL='https://dashscope-intl.aliyuncs.com/compatible-mode/v1'" >> ~/.bashrc   
    
    source ~/.bashrc
    
    # Check if it took effect
    echo $DASHSCOPE_API_KEY
    echo $DASHSCOPE_BASE_URL  
  • Configure the AnalyticDB for MySQL connection information as environment variables.

    cd ReMe
    mv example.env .env

    Edit the .env file. Replace the following content with your actual configuration.

    FLOW_EMBEDDING_API_KEY=<YOUR_DASHSCOPE_API_KEY>
    FLOW_EMBEDDING_BASE_URL=<YOUR_DASHSCOPE_BASE_URL>
    FLOW_LLM_API_KEY=<YOUR_DASHSCOPE_API_KEY>
    FLOW_LLM_BASE_URL=<YOUR_DASHSCOPE_BASE_URL>
    
    ADB_HOST=<YOUR_ADB_HOST>
    ADB_PORT=3306
    ADB_USER=<YOUR_ADB_USER>
    ADB_PASSWORD=<YOUR_ADB_PASSWORD>
    ADB_DATABASE=reme
  • Start the ReMe service.

    • Run the following command to start the ReMe service.

      cd ReMe
      reme \
        backend=http \
        http.port=8002 \
        llm.default.model_name=qwen3-max \
        embedding_model.default.model_name=text-embedding-v4 \
        vector_store.default.backend=aliyun_adb_mysql
    • After the service starts successfully, the console displays the service status.

      image

    • Startup parameter descriptions:

      Parameter

      Description

      LLM

      Uses the qwen3-max model from Alibaba Cloud Model Studio (can be replaced with other supported models)

      Embedder

      Uses the text-embedding-v4 model from Alibaba Cloud Model Studio, with 1536 vector dimensions

      vector_store

      Uses AnalyticDB for MySQL as the vector store backend

Core Memory Operations Demo

  • Personal Memory

    Personal Memory stores and retrieves static information related to a specific user, such as name, occupation, and hobbies.

    • Run the Demo:

      cd ReMe
      python3 ./cookbook/simple_demo/use_personal_memory_demo.py
    • Analysis of results:

      1. Create a conversation and fetch information: The demo first inputs the user's personal information, such as name, occupation, and interests, through a multi-turn conversation. ReMe automatically fetches this information from the conversation and stores it in Personal Memory.

      2. Memory summarization and storage: The system summarizes the extracted information into structured memory entries that contain metadata, such as keywords, source messages, and observation types, and persists these entries to AnalyticDB for MySQL.

      3. Semantic retrieval validation: Finally, the demo validates the memory retrieval performance by asking a series of natural language questions.

    • Retrieval examples and expected results from the Demo:

      lhj@B-F21WMGFD-2205 ReMe % python3 ./cookbook/simple_demo/use_personal_memory_demo.py 
      Clearing existing memories...
      {"answer": "", "messages": [], "success": true, "metadata": {"action_result": ""}}
      
      Creating conversation with personal information...
      
      Summarizing personal memories...
      {
        "answer": "",
        "messages": [],
        "success": true,
        "metadata": {
          "memory_list": [
            {
              "workspace_id": "personal_memory_demo",
              "memory_id": "7f253fb5ab75402eaa84e23cee76ef52",
              "memory_type": "personal",
              "when_to_use": "John Smith, 28 years old, tech company, San Francisco",
              "content": "user's name is John Smith, age 28, works at a tech company in San Francisco",
              "score": 0.0,
              "time_created": "2025-11-04 17:22:50",
              "time_modified": "2025-11-04 17:22:50",
              "author": "qwen3-max",
              "metadata": {
                "keywords": "John Smith, 28 years old, tech company, San Francisco",
                "source_message": "My name is John Smith, I'm 28 years old, and I work at a tech company in San Francisco",
                "observation_type": "personal_info"
              },
              "target": "user",
              "reflection_subject": ""
            },
            {
              "workspace_id": "personal_memory_demo",
              "memory_id": "d423370cfa5e47e2b53f5c77f4e2353e",
              "memory_type": "personal",
              "when_to_use": "software engineer, backend development, Python, Go",
              "content": "user is a software engineer specializing in backend development with Python and Go",
              "score": 0.0,
              "time_created": "2025-11-04 17:22:50",
              "time_modified": "2025-11-04 17:22:50",
              "author": "qwen3-max",
              "metadata": {
                "keywords": "software engineer, backend development, Python, Go",
                "source_message": "I'm a software engineer, mainly doing backend development using Python and Go",
                "observation_type": "personal_info"
              },
              "target": "user",
              "reflection_subject": ""
            },
            {
              "workspace_id": "personal_memory_demo",
              "memory_id": "88474b71f7f24ac3961a349914407250",
              "memory_type": "personal",
              "when_to_use": "basketball, sci-fi movies, Dune Part 2",
              "content": "user enjoys playing basketball and watching sci-fi movies, recently watched Dune Part 2",
              "score": 0.0,
              "time_created": "2025-11-04 17:22:50",
              "time_modified": "2025-11-04 17:22:50",
              "author": "qwen3-max",
              "metadata": {
                "keywords": "basketball, sci-fi movies, Dune Part 2",
                "source_message": "I enjoy playing basketball and watching sci-fi movies. I recently watched Dune Part 2",
                "observation_type": "personal_info"
              },
              "target": "user",
              "reflection_subject": ""
            },
            {
              "workspace_id": "personal_memory_demo",
              "memory_id": "9a8b4f81c66b4068b2e53146374ebc7a",
              "memory_type": "personal",
              "when_to_use": "cat, Shadow, pet",
              "content": "user has a 3-year-old cat named Shadow",
              "score": 0.0,
              "time_created": "2025-11-04 17:22:50",
              "time_modified": "2025-11-04 17:22:50",
              "author": "qwen3-max",
              "metadata": {
                "keywords": "cat, Shadow, pet",
                "source_message": "I have a cat named Shadow who is 3 years old",
                "observation_type": "personal_info"
              },
              "target": "user",
              "reflection_subject": ""
            },
            {
              "workspace_id": "personal_memory_demo",
              "memory_id": "b72a6d0927e04ea7a2de9e28b4c008ec",
              "memory_type": "personal",
              "when_to_use": "Japanese cuisine, sushi, ramen",
              "content": "user is interested in Japanese cuisine, especially sushi and ramen",
              "score": 0.0,
              "time_created": "2025-11-04 17:22:50",
              "time_modified": "2025-11-04 17:22:50",
              "author": "qwen3-max",
              "metadata": {
                "keywords": "Japanese cuisine, sushi, ramen",
                "source_message": "I'm really interested in Japanese cuisine, especially sushi and ramen",
                "observation_type": "personal_info"
              },
              "target": "user",
              "reflection_subject": ""
            },
            {
              "workspace_id": "personal_memory_demo",
              "memory_id": "f900b79060804a1587d59032c63f1e3c",
              "memory_type": "personal",
              "when_to_use": "Japan, Tokyo, Kyoto, trip",
              "content": "user is planning a trip to Tokyo and Kyoto in December 2025",
              "score": 0.0,
              "time_created": "2025-11-04 17:22:46",
              "time_modified": "2025-11-04 17:22:46",
              "author": "qwen3-max",
              "metadata": {
                "keywords": "Japan, Tokyo, Kyoto, trip",
                "time_info": "December 2025",
                "source_message": "I'm planning a trip to Japan next month, mainly to Tokyo and Kyoto",
                "observation_type": "personal_info_with_time"
              },
              "target": "user",
              "reflection_subject": ""
            }
          ],
          "deleted_memory_ids": [],
          "update_result": {
            "deleted_count": 0,
            "inserted_count": 6
          }
        }
      }
      
      Waiting for memories to be processed...
      
      Retrieving personal memories...
      
      Query: What's my name and age?
      {
        "answer": "user's name is John Smith, age 28, works at a tech company in San Francisco\nuser has a 3-year-old cat named Shadow\nuser is planning a trip to Tokyo and Kyoto in December 2025",
        "messages": [],
        "success": true,
        "metadata": {
          "memory_list": [
            {
              "workspace_id": "personal_memory_demo",
              "memory_id": "7f253fb5ab75402eaa84e23cee76ef52",
              "memory_type": "personal",
              "when_to_use": "John Smith, 28 years old, tech company, San Francisco",
              "content": "user's name is John Smith, age 28, works at a tech company in San Francisco",
              "score": 0.038895229,
              "time_created": "2025-11-04 17:22:50",
              "time_modified": "2025-11-04 17:22:50",
              "author": "qwen3-max",
              "metadata": {
                "keywords": "John Smith, 28 years old, tech company, San Francisco",
                "source_message": "My name is John Smith, I'm 28 years old, and I work at a tech company in San Francisco",
                "observation_type": "personal_info",
                "match_event_flag": "0",
                "match_msg_flag": "0"
              },
              "target": "user",
              "reflection_subject": ""
            },
            {
              "workspace_id": "personal_memory_demo",
              "memory_id": "9a8b4f81c66b4068b2e53146374ebc7a",
              "memory_type": "personal",
              "when_to_use": "cat, Shadow, pet",
              "content": "user has a 3-year-old cat named Shadow",
              "score": 0.027221944999999997,
              "time_created": "2025-11-04 17:22:50",
              "time_modified": "2025-11-04 17:22:50",
              "author": "qwen3-max",
              "metadata": {
                "keywords": "cat, Shadow, pet",
                "source_message": "I have a cat named Shadow who is 3 years old",
                "observation_type": "personal_info",
                "match_event_flag": "0",
                "match_msg_flag": "0"
              },
              "target": "user",
              "reflection_subject": ""
            },
            {
              "workspace_id": "personal_memory_demo",
              "memory_id": "f900b79060804a1587d59032c63f1e3c",
              "memory_type": "personal",
              "when_to_use": "Japan, Tokyo, Kyoto, trip",
              "content": "user is planning a trip to Tokyo and Kyoto in December 2025",
              "score": 0.024106982,
              "time_created": "2025-11-04 17:22:46",
              "time_modified": "2025-11-04 17:22:46",
              "author": "qwen3-max",
              "metadata": {
                "keywords": "Japan, Tokyo, Kyoto, trip",
                "time_info": "December 2025",
                "source_message": "I'm planning a trip to Japan next month, mainly to Tokyo and Kyoto",
                "observation_type": "personal_info_with_time",
                "match_event_flag": "0",
                "match_msg_flag": "0"
              },
              "target": "user",
              "reflection_subject": ""
            }
          ]
        }
      }
      
      Query: What do I do for work?
      {
        "answer": "user's name is John Smith, age 28, works at a tech company in San Francisco\nuser is a software engineer specializing in backend development with Python and Go\nuser is planning a trip to Tokyo and Kyoto in December 2025",
        "messages": [],
        "success": true,
        "metadata": {
          "memory_list": [
            {
              "workspace_id": "personal_memory_demo",
              "memory_id": "7f253fb5ab75402eaa84e23cee76ef52",
              "memory_type": "personal",
              "when_to_use": "John Smith, 28 years old, tech company, San Francisco",
              "content": "user's name is John Smith, age 28, works at a tech company in San Francisco",
              "score": 0.029179364000000003,
              "time_created": "2025-11-04 17:22:50",
              "time_modified": "2025-11-04 17:22:50",
              "author": "qwen3-max",
              "metadata": {
                "keywords": "John Smith, 28 years old, tech company, San Francisco",
                "source_message": "My name is John Smith, I'm 28 years old, and I work at a tech company in San Francisco",
                "observation_type": "personal_info",
                "match_event_flag": "0",
                "match_msg_flag": "0"
              },
              "target": "user",
              "reflection_subject": ""
            },
            {
              "workspace_id": "personal_memory_demo",
              "memory_id": "d423370cfa5e47e2b53f5c77f4e2353e",
              "memory_type": "personal",
              "when_to_use": "software engineer, backend development, Python, Go",
              "content": "user is a software engineer specializing in backend development with Python and Go",
              "score": 0.024785686,
              "time_created": "2025-11-04 17:22:50",
              "time_modified": "2025-11-04 17:22:50",
              "author": "qwen3-max",
              "metadata": {
                "keywords": "software engineer, backend development, Python, Go",
                "source_message": "I'm a software engineer, mainly doing backend development using Python and Go",
                "observation_type": "personal_info",
                "match_event_flag": "0",
                "match_msg_flag": "0"
              },
              "target": "user",
              "reflection_subject": ""
            },
            {
              "workspace_id": "personal_memory_demo",
              "memory_id": "f900b79060804a1587d59032c63f1e3c",
              "memory_type": "personal",
              "when_to_use": "Japan, Tokyo, Kyoto, trip",
              "content": "user is planning a trip to Tokyo and Kyoto in December 2025",
              "score": 0.017342727,
              "time_created": "2025-11-04 17:22:46",
              "time_modified": "2025-11-04 17:22:46",
              "author": "qwen3-max",
              "metadata": {
                "keywords": "Japan, Tokyo, Kyoto, trip",
                "time_info": "December 2025",
                "source_message": "I'm planning a trip to Japan next month, mainly to Tokyo and Kyoto",
                "observation_type": "personal_info_with_time",
                "match_event_flag": "0",
                "match_msg_flag": "0"
              },
              "target": "user",
              "reflection_subject": ""
            }
          ]
        }
      }
      
      Query: What are my hobbies?
      {
        "answer": "user is planning a trip to Tokyo and Kyoto in December 2025\nuser is a software engineer specializing in backend development with Python and Go\nuser is interested in Japanese cuisine, especially sushi and ramen",
        "messages": [],
        "success": true,
        "metadata": {
          "memory_list": [
            {
              "workspace_id": "personal_memory_demo",
              "memory_id": "f900b79060804a1587d59032c63f1e3c",
              "memory_type": "personal",
              "when_to_use": "Japan, Tokyo, Kyoto, trip",
              "content": "user is planning a trip to Tokyo and Kyoto in December 2025",
              "score": 0.025223058,
              "time_created": "2025-11-04 17:22:46",
              "time_modified": "2025-11-04 17:22:46",
              "author": "qwen3-max",
              "metadata": {
                "keywords": "Japan, Tokyo, Kyoto, trip",
                "time_info": "December 2025",
                "source_message": "I'm planning a trip to Japan next month, mainly to Tokyo and Kyoto",
                "observation_type": "personal_info_with_time",
                "match_event_flag": "0",
                "match_msg_flag": "0"
              },
              "target": "user",
              "reflection_subject": ""
            },
            {
              "workspace_id": "personal_memory_demo",
              "memory_id": "d423370cfa5e47e2b53f5c77f4e2353e",
              "memory_type": "personal",
              "when_to_use": "software engineer, backend development, Python, Go",
              "content": "user is a software engineer specializing in backend development with Python and Go",
              "score": 0.024959816000000003,
              "time_created": "2025-11-04 17:22:50",
              "time_modified": "2025-11-04 17:22:50",
              "author": "qwen3-max",
              "metadata": {
                "keywords": "software engineer, backend development, Python, Go",
                "source_message": "I'm a software engineer, mainly doing backend development using Python and Go",
                "observation_type": "personal_info",
                "match_event_flag": "0",
                "match_msg_flag": "0"
              },
              "target": "user",
              "reflection_subject": ""
            },
            {
              "workspace_id": "personal_memory_demo",
              "memory_id": "b72a6d0927e04ea7a2de9e28b4c008ec",
              "memory_type": "personal",
              "when_to_use": "Japanese cuisine, sushi, ramen",
              "content": "user is interested in Japanese cuisine, especially sushi and ramen",
              "score": 0.020527664,
              "time_created": "2025-11-04 17:22:50",
              "time_modified": "2025-11-04 17:22:50",
              "author": "qwen3-max",
              "metadata": {
                "keywords": "Japanese cuisine, sushi, ramen",
                "source_message": "I'm really interested in Japanese cuisine, especially sushi and ramen",
                "observation_type": "personal_info",
                "match_event_flag": "0",
                "match_msg_flag": "0"
              },
              "target": "user",
              "reflection_subject": ""
            }
          ]
        }
      }
      
      Query: Do I have any pets?
      {
        "answer": "user has a 3-year-old cat named Shadow\nuser's name is John Smith, age 28, works at a tech company in San Francisco\nuser is planning a trip to Tokyo and Kyoto in December 2025",
        "messages": [],
        "success": true,
        "metadata": {
          "memory_list": [
            {
              "workspace_id": "personal_memory_demo",
              "memory_id": "9a8b4f81c66b4068b2e53146374ebc7a",
              "memory_type": "personal",
              "when_to_use": "cat, Shadow, pet",
              "content": "user has a 3-year-old cat named Shadow",
              "score": 0.044214043,
              "time_created": "2025-11-04 17:22:50",
              "time_modified": "2025-11-04 17:22:50",
              "author": "qwen3-max",
              "metadata": {
                "keywords": "cat, Shadow, pet",
                "source_message": "I have a cat named Shadow who is 3 years old",
                "observation_type": "personal_info",
                "match_event_flag": "0",
                "match_msg_flag": "0"
              },
              "target": "user",
              "reflection_subject": ""
            },
            {
              "workspace_id": "personal_memory_demo",
              "memory_id": "7f253fb5ab75402eaa84e23cee76ef52",
              "memory_type": "personal",
              "when_to_use": "John Smith, 28 years old, tech company, San Francisco",
              "content": "user's name is John Smith, age 28, works at a tech company in San Francisco",
              "score": 0.026690182000000003,
              "time_created": "2025-11-04 17:22:50",
              "time_modified": "2025-11-04 17:22:50",
              "author": "qwen3-max",
              "metadata": {
                "keywords": "John Smith, 28 years old, tech company, San Francisco",
                "source_message": "My name is John Smith, I'm 28 years old, and I work at a tech company in San Francisco",
                "observation_type": "personal_info",
                "match_event_flag": "0",
                "match_msg_flag": "0"
              },
              "target": "user",
              "reflection_subject": ""
            },
            {
              "workspace_id": "personal_memory_demo",
              "memory_id": "f900b79060804a1587d59032c63f1e3c",
              "memory_type": "personal",
              "when_to_use": "Japan, Tokyo, Kyoto, trip",
              "content": "user is planning a trip to Tokyo and Kyoto in December 2025",
              "score": 0.023277275,
              "time_created": "2025-11-04 17:22:46",
              "time_modified": "2025-11-04 17:22:46",
              "author": "qwen3-max",
              "metadata": {
                "keywords": "Japan, Tokyo, Kyoto, trip",
                "time_info": "December 2025",
                "source_message": "I'm planning a trip to Japan next month, mainly to Tokyo and Kyoto",
                "observation_type": "personal_info_with_time",
                "match_event_flag": "0",
                "match_msg_flag": "0"
              },
              "target": "user",
              "reflection_subject": ""
            }
          ]
        }
      }
      
      Query: What are my travel plans?
      {
        "answer": "user is planning a trip to Tokyo and Kyoto in December 2025\nuser's name is John Smith, age 28, works at a tech company in San Francisco\nuser is a software engineer specializing in backend development with Python and Go",
        "messages": [],
        "success": true,
        "metadata": {
          "memory_list": [
            {
              "workspace_id": "personal_memory_demo",
              "memory_id": "f900b79060804a1587d59032c63f1e3c",
              "memory_type": "personal",
              "when_to_use": "Japan, Tokyo, Kyoto, trip",
              "content": "user is planning a trip to Tokyo and Kyoto in December 2025",
              "score": 0.04186047600000001,
              "time_created": "2025-11-04 17:22:46",
              "time_modified": "2025-11-04 17:22:46",
              "author": "qwen3-max",
              "metadata": {
                "keywords": "Japan, Tokyo, Kyoto, trip",
                "time_info": "December 2025",
                "source_message": "I'm planning a trip to Japan next month, mainly to Tokyo and Kyoto",
                "observation_type": "personal_info_with_time",
                "match_event_flag": "0",
                "match_msg_flag": "0"
              },
              "target": "user",
              "reflection_subject": ""
            },
            {
              "workspace_id": "personal_memory_demo",
              "memory_id": "7f253fb5ab75402eaa84e23cee76ef52",
              "memory_type": "personal",
              "when_to_use": "John Smith, 28 years old, tech company, San Francisco",
              "content": "user's name is John Smith, age 28, works at a tech company in San Francisco",
              "score": 0.025156727000000004,
              "time_created": "2025-11-04 17:22:50",
              "time_modified": "2025-11-04 17:22:50",
              "author": "qwen3-max",
              "metadata": {
                "keywords": "John Smith, 28 years old, tech company, San Francisco",
                "source_message": "My name is John Smith, I'm 28 years old, and I work at a tech company in San Francisco",
                "observation_type": "personal_info",
                "match_event_flag": "0",
                "match_msg_flag": "0"
              },
              "target": "user",
              "reflection_subject": ""
            },
            {
              "workspace_id": "personal_memory_demo",
              "memory_id": "d423370cfa5e47e2b53f5c77f4e2353e",
              "memory_type": "personal",
              "when_to_use": "software engineer, backend development, Python, Go",
              "content": "user is a software engineer specializing in backend development with Python and Go",
              "score": 0.019123243,
              "time_created": "2025-11-04 17:22:50",
              "time_modified": "2025-11-04 17:22:50",
              "author": "qwen3-max",
              "metadata": {
                "keywords": "software engineer, backend development, Python, Go",
                "source_message": "I'm a software engineer, mainly doing backend development using Python and Go",
                "observation_type": "personal_info",
                "match_event_flag": "0",
                "match_msg_flag": "0"
              },
              "target": "user",
              "reflection_subject": ""
            }
          ]
        }
      }
      
      Query: What foods do I like?
      {
        "answer": "user is interested in Japanese cuisine, especially sushi and ramen\nuser is planning a trip to Tokyo and Kyoto in December 2025\nuser is a software engineer specializing in backend development with Python and Go",
        "messages": [],
        "success": true,
        "metadata": {
          "memory_list": [
            {
              "workspace_id": "personal_memory_demo",
              "memory_id": "b72a6d0927e04ea7a2de9e28b4c008ec",
              "memory_type": "personal",
              "when_to_use": "Japanese cuisine, sushi, ramen",
              "content": "user is interested in Japanese cuisine, especially sushi and ramen",
              "score": 0.0316972,
              "time_created": "2025-11-04 17:22:50",
              "time_modified": "2025-11-04 17:22:50",
              "author": "qwen3-max",
              "metadata": {
                "keywords": "Japanese cuisine, sushi, ramen",
                "source_message": "I'm really interested in Japanese cuisine, especially sushi and ramen",
                "observation_type": "personal_info",
                "match_event_flag": "0",
                "match_msg_flag": "0"
              },
              "target": "user",
              "reflection_subject": ""
            },
            {
              "workspace_id": "personal_memory_demo",
              "memory_id": "f900b79060804a1587d59032c63f1e3c",
              "memory_type": "personal",
              "when_to_use": "Japan, Tokyo, Kyoto, trip",
              "content": "user is planning a trip to Tokyo and Kyoto in December 2025",
              "score": 0.022572586000000002,
              "time_created": "2025-11-04 17:22:46",
              "time_modified": "2025-11-04 17:22:46",
              "author": "qwen3-max",
              "metadata": {
                "keywords": "Japan, Tokyo, Kyoto, trip",
                "time_info": "December 2025",
                "source_message": "I'm planning a trip to Japan next month, mainly to Tokyo and Kyoto",
                "observation_type": "personal_info_with_time",
                "match_event_flag": "0",
                "match_msg_flag": "0"
              },
              "target": "user",
              "reflection_subject": ""
            },
            {
              "workspace_id": "personal_memory_demo",
              "memory_id": "d423370cfa5e47e2b53f5c77f4e2353e",
              "memory_type": "personal",
              "when_to_use": "software engineer, backend development, Python, Go",
              "content": "user is a software engineer specializing in backend development with Python and Go",
              "score": 0.021622963000000002,
              "time_created": "2025-11-04 17:22:50",
              "time_modified": "2025-11-04 17:22:50",
              "author": "qwen3-max",
              "metadata": {
                "keywords": "software engineer, backend development, Python, Go",
                "source_message": "I'm a software engineer, mainly doing backend development using Python and Go",
                "observation_type": "personal_info",
                "match_event_flag": "0",
                "match_msg_flag": "0"
              },
              "target": "user",
              "reflection_subject": ""
            }
          ]
        }
      }

      Query Question

      Expected Retrieval Result

      "What do I do for work?"

      Returns work-related memories (software engineer, Python/Go backend development).

      "What are my hobbies?"

      Returns hobby-related memories (Japanese cuisine, travel plans).

      "Do I have any pets?"

      Returns pet-related memories (3-year-old cat Shadow).

  • Task Memory

    Task Memory records the experience and methodologies that an Agent accumulates while completing specific tasks. This allows the Agent to reuse this experience when handling similar future tasks, which improves efficiency and quality.

    • Run the Demo:

      cd ReMe
      python3 ./cookbook/simple_demo/use_task_memory_demo.py
    • Analysis of execution results:

      1. Initial task execution: The Agent receives the task "Analyze Tesla Company." It breaks the task down into six dimensions, such as company overview, financial performance, and technological innovation. Then, it collects information using search tools.

      2. Methodology refinement: After the task is complete, the system extracts reusable methodological experience from the execution process. For example:

        • Breaking down a complex analysis task into multiple subtasks.

        • Filling information gaps using a two-stage retrieval strategy.

        • Organizing the output structure to improve report readability.

      3. Memory reuse: When the Agent receives a similar new task, such as "Analyze Xiaomi Company", the system automatically retrieves and applies the previously accumulated task experience. This generates an enhanced, optimized query strategy to produce more comprehensive and logically structured analysis results.

    • Retrieval examples and expected results from the Demo:

      === Task Memory Demo ===
      
      1. Deleting workspace...
      Workspace 'test_workspace' deleted successfully
      
      2. Running agent with first query...
      Agent response: I have gathered comprehensive information about Xiaomi Corporation through multiple targeted searches. Here's a summary of the analysis:
      
      1. **Company Overview**: Xiaomi Corporation is a Chinese multinational technology company founded in 2010, known for its smartphones, smart home devices, and IoT ecosystem. It operates globally with a strong presence in Asia, Europe, and Latin America.
      
      2. **Financial Performance (2024)**: Xiaomi reported robust financial results in 2024, with significant revenue growth driven by smartphone sales and expansion in its Internet of Things (IoT) product lines. The company maintained profitability despite global economic challenges.
      
      3. **Product Portfolio & Innovations**: Xiaomi continues to innovate in areas such as high-performance smartphones (e.g., Mi series), foldable phones, electric vehicles (Xiaomi SU7), and an expanding range of smart home products integrated into its MIUI ecosystem.
      
      4. **Market Position**: Xiaomi remains one of the top five global smartphone manufacturers, particularly strong in emerging markets. Its competitive pricing strategy and focus on value-for-money products have helped it gain market share.
      
      5. **Challenges & Risks (2025)**: Key challenges include increasing competition from brands like Samsung, Apple, and Oppo, supply chain volatility, geopolitical tensions affecting international operations, and the need to sustain innovation in the EV sector.
      
      6. **Recent Developments (2025)**: In early 2025, Xiaomi launched its new electric vehicle model, the SU7 Pro, which received positive reviews. The company also expanded its AI-powered smart home platform and strengthened partnerships in Southeast Asia and Europe.
      
      This analysis provides a holistic view of Xiaomi Corporation’s current status, strategic direction, and future outlook.
      Messages saved to messages.jsonl
      
      3. Running memory-augmented agent workflow...
      
      --- Building memories with query: 'Analyze the company Tesla.' ---
      Agent response: I have gathered comprehensive information about Tesla through multiple search queries. Here is a summary of the key aspects:
      
      1. **Company Overview**: Tesla, Inc. is an American electric vehicle and clean energy company founded in 2003 by Martin Eberhard and Marc Tarpenning, with Elon Musk playing a pivotal role since 2004. The company designs, manufactures, and sells electric vehicles (EVs), solar panels, and energy storage systems.
      
      2. **Financial Performance (2024)**: Tesla reported strong financial results in 2024, with increased revenue driven by higher vehicle deliveries and growth in its energy products segment. However, the company faced challenges related to production scaling and global economic conditions affecting demand.
      
      3. **Recent Innovations and Technology Developments**: Tesla continues to lead in EV technology, including advancements in battery efficiency, autonomous driving (Full Self-Driving or FSD), and the development of next-generation platforms like the "Tesla Model 2" (rumored). The company also expanded its AI capabilities through projects like Optimus (humanoid robot).
      
      4. **CEO Elon Musk's Recent Activities**: Elon Musk has been actively involved in public discussions about AI ethics, infrastructure projects (e.g., Hyperloop), and the future of transportation. He has also engaged in high-profile social media interactions and strategic decisions impacting Tesla’s direction.
      
      5. **Market Position and Competition**: Tesla remains a dominant player in the global EV market, though it faces increasing competition from traditional automakers (e.g., Ford, Volkswagen) and new entrants (e.g., BYD, Rivian). Despite this, Tesla maintains a strong brand presence and technological edge.
      
      6. **Environmental Impact and Sustainability Initiatives**: Tesla is committed to reducing carbon emissions through its products and operations. The company emphasizes sustainable manufacturing practices, renewable energy integration, and recycling programs for batteries.
      
      This analysis provides a well-rounded view of Tesla’s current status, challenges, and future outlook.
      
      --- Summarizing conversation to create memories ---
      Memory list: [{'workspace_id': 'test_workspace', 'memory_id': '4a0f9408ee2b4cdda721d6bfed8a0a24', 'memory_type': 'task', 'when_to_use': 'When analyzing a complex, multi-faceted entity like a major corporation that requires coverage across business, financial, technological, leadership, competitive, and sustainability dimensions.', 'content': "The agent decomposed the broad request 'Analyze the company Tesla' into six distinct thematic subtasks (overview, financials, innovation, leadership, competition, sustainability) and executed parallel and sequential tool calls to gather targeted information. This structured decomposition ensured comprehensive coverage without redundancy, while iterative querying allowed refinement based on emerging context.", 'score': 0.85, 'time_created': '2025-11-04 19:35:23', 'time_modified': '2025-11-04 19:35:23', 'author': 'qwen3-max', 'metadata': {'when_to_use': 'When analyzing a complex, multi-faceted entity like a major corporation that requires coverage across business, financial, technological, leadership, competitive, and sustainability dimensions.', 'experience': "The agent decomposed the broad request 'Analyze the company Tesla' into six distinct thematic subtasks (overview, financials, innovation, leadership, competition, sustainability) and executed parallel and sequential tool calls to gather targeted information. This structured decomposition ensured comprehensive coverage without redundancy, while iterative querying allowed refinement based on emerging context.", 'tags': ['problem decomposition', 'multi-perspective analysis', 'corporate analysis', 'iterative search'], 'confidence': 0.95, 'step_type': 'reasoning', 'tools_used': ['dashscope_search']}}, {'workspace_id': 'test_workspace', 'memory_id': '51ddcd1b679e45fc86aacd5982a1cc54', 'memory_type': 'task', 'when_to_use': 'When initial information gathering is insufficient to form a holistic answer, and additional contextual layers (e.g., leadership impact or market dynamics) are needed to enrich understanding.', 'content': 'After an initial round of three searches, the agent proactively identified gaps—specifically around leadership influence and competitive landscape—and issued a second wave of targeted queries. This adaptive two-phase retrieval strategy demonstrates effective metacognition: assessing coverage completeness and filling critical knowledge gaps before synthesis.', 'score': 0.85, 'time_created': '2025-11-04 19:35:23', 'time_modified': '2025-11-04 19:35:23', 'author': 'qwen3-max', 'metadata': {'when_to_use': 'When initial information gathering is insufficient to form a holistic answer, and additional contextual layers (e.g., leadership impact or market dynamics) are needed to enrich understanding.', 'experience': 'After an initial round of three searches, the agent proactively identified gaps—specifically around leadership influence and competitive landscape—and issued a second wave of targeted queries. This adaptive two-phase retrieval strategy demonstrates effective metacognition: assessing coverage completeness and filling critical knowledge gaps before synthesis.', 'tags': ['adaptive querying', 'gap analysis', 'context enrichment', 'sequential tool use'], 'confidence': 0.9, 'step_type': 'decision', 'tools_used': ['dashscope_search']}}, {'workspace_id': 'test_workspace', 'memory_id': '79e7bb2e055640f3975c12c719e10092', 'memory_type': 'task', 'when_to_use': 'When synthesizing information from multiple heterogeneous sources into a coherent, structured summary for user consumption.', 'content': 'The final response organized findings into six clearly labeled thematic sections that directly mirrored the query decomposition strategy. This alignment between information-gathering structure and output format enhanced clarity, reduced cognitive load, and ensured all subtasks were visibly addressed—demonstrating strong traceability from intent to delivery.', 'score': 0.85, 'time_created': '2025-11-04 19:35:23', 'time_modified': '2025-11-04 19:35:23', 'author': 'qwen3-max', 'metadata': {'when_to_use': 'When synthesizing information from multiple heterogeneous sources into a coherent, structured summary for user consumption.', 'experience': 'The final response organized findings into six clearly labeled thematic sections that directly mirrored the query decomposition strategy. This alignment between information-gathering structure and output format enhanced clarity, reduced cognitive load, and ensured all subtasks were visibly addressed—demonstrating strong traceability from intent to delivery.', 'tags': ['structured synthesis', 'thematic organization', 'answer coherence', 'user-centric summarization'], 'confidence': 0.85, 'step_type': 'action', 'tools_used': []}}]
      Memory saved to memory.jsonl
      
      --- Retrieving memories for query: 'Analyze Xiaomi Corporation' ---
      Retrieved memory: To effectively analyze Xiaomi Corporation, adopt a structured, multi-dimensional approach that systematically examines its core business segments, financial performance, technological innovation, leadership strategy, competitive positioning, and sustainability initiatives. Begin by decomposing the analysis into these six thematic pillars to ensure comprehensive coverage without redundancy. Use parallel and sequential information-gathering methods to collect targeted data on each dimension—starting with Xiaomi’s product ecosystem (smartphones, IoT, EVs), revenue streams, and geographic footprint. If initial findings lack depth in critical areas such as leadership vision or competitive dynamics in key markets like China, India, or Europe, proactively issue follow-up queries to fill those gaps. This adaptive two-phase retrieval ensures a holistic understanding before synthesis. Finally, organize the output into clearly labeled sections that mirror the original analytical framework, creating a coherent, traceable narrative that directly addresses the user’s request while minimizing cognitive load. This method—proven effective for complex corporate analyses like Tesla—ensures actionable, well-rounded insights tailored to Xiaomi’s unique position at the intersection of consumer electronics, smart hardware, and emerging mobility.
      
      --- Running agent with memory-augmented query ---
      Augmented query: To effectively analyze Xiaomi Corporation, adopt a structured, multi-dimensional approach that systematically examines its core business segments, financial performance, technological innovation, leadership strategy, competitive positioning, and sustainability initiatives. Begin by decomposing the analysis into these six thematic pillars to ensure comprehensive coverage without redundancy. Use parallel and sequential information-gathering methods to collect targeted data on each dimension—starting with Xiaomi’s product ecosystem (smartphones, IoT, EVs), revenue streams, and geographic footprint. If initial findings lack depth in critical areas such as leadership vision or competitive dynamics in key markets like China, India, or Europe, proactively issue follow-up queries to fill those gaps. This adaptive two-phase retrieval ensures a holistic understanding before synthesis. Finally, organize the output into clearly labeled sections that mirror the original analytical framework, creating a coherent, traceable narrative that directly addresses the user’s request while minimizing cognitive load. This method—proven effective for complex corporate analyses like Tesla—ensures actionable, well-rounded insights tailored to Xiaomi’s unique position at the intersection of consumer electronics, smart hardware, and emerging mobility.
      
      User Question:
      Analyze Xiaomi Corporation
      Agent response: Based on the comprehensive analysis of Xiaomi Corporation, here is a structured overview across key dimensions:
      
      ### 1. **Business Segments & Product Ecosystem**
      Xiaomi operates through three core segments:
      - **Smartphones**: A cornerstone of its business, with a strong global presence.
      - **IoT and Smart Home Devices**: A rapidly growing segment including wearables, home appliances, and smart lighting. Xiaomi’s ecosystem approach integrates hardware, software, and services.
      - **Electric Vehicles (EVs)**: A strategic new venture launched in 2021, with the Mi EV model entering production. This marks a significant pivot into mobility.
      
      ### 2. **Financial Performance & Revenue Streams**
      In 2024, Xiaomi reported robust financial performance:
      - Revenue growth driven by smartphone sales and IoT expansion.
      - Diversified revenue streams: smartphones (~50%), IoT (~30%), and EVs (~20% projected).
      - Strong profitability in key markets like China and India, with increasing margins from high-margin IoT products.
      
      ### 3. **Technological Innovation**
      Xiaomi is investing heavily in R&D:
      - Development of proprietary AI chips (e.g., Surge series) to enhance performance in smartphones and IoT devices.
      - Focus on AI integration across its ecosystem, including voice assistants and smart home automation.
      - Advancements in battery technology and energy efficiency for both mobile and EV platforms.
      
      ### 4. **Leadership Strategy & Vision**
      Under CEO Lei Jun, Xiaomi’s strategy emphasizes:
      - "Internet + Hardware + Software" integration to create seamless user experiences.
      - Long-term vision of building a global smart lifestyle ecosystem.
      - Strategic focus on innovation, cost-efficiency, and rapid market entry.
      
      ### 5. **Competitive Positioning**
      Xiaomi holds strong positions in key markets:
      - **China**: One of the top 3 smartphone vendors, leveraging brand loyalty and affordable premium offerings.
      - **India**: Market leader in smartphones, with aggressive pricing and extensive retail networks.
      - **Europe**: Rapidly gaining share, particularly in mid-to-high-end segments, due to design quality and value-for-money propositions.
      
      ### 6. **Sustainability & Future Initiatives**
      Xiaomi is advancing sustainability efforts:
      - Commitment to carbon neutrality goals by 2030.
      - Eco-friendly materials in packaging and product design.
      - EV development aligns with global green mobility trends, with zero-emission vehicles under development.
      
      ### Additional Insights
      - **Global Expansion**: Aggressive international rollout via online platforms and local partnerships, especially in Southeast Asia, Latin America, and Europe.
      - **Supply Chain**: Collaborates with leading manufacturers (e.g., Foxconn, BYD) while maintaining control over core R&D and design.
      - **Consumer Loyalty**: High customer retention due to ecosystem lock-in and consistent product quality.
      
      Xiaomi’s future success hinges on its ability to scale EV production, deepen AI integration, and maintain its competitive edge in emerging markets.
      
      4. Dumping memory to disk...
      Memory dumped to ./
      
      5. Loading memory from disk...
      Memory loaded from ./
      
      === Demo Complete ===
  • Tool Memory

    Tool Memory records an Agent's experience using various tools, such as APIs and functions. This includes the tool's core functions, success patterns, common issues, and best practices.

    • Run the Demo:

      cd ReMe
      python3 ./cookbook/simple_demo/use_tool_memory_demo.py
    • Analysis of results:

      1. Simulate tool calls: The demo first simulates 70 tool call records for three tools: database_query, file_processor, and web_search.

      2. Generate experience summaries: The system automatically analyzes these call records and generates a detailed usage experience summary for each tool. The summary includes the following key dimensions:

        Dimension

        Description

        Core feature

        The main purpose and applicable scenarios for the tool.

        Success patterns

        Typical conditions and parameter combinations for successful tool calls.

        FAQ

        Analysis of common reasons for failed tool calls.

        Best practices

        Usage recommendations and precautions.

        Statistics

        Quantitative metrics such as success rate, average time consumed, and average token consumption.

    • Retrieval examples and expected results from the Demo:

      2025-11-04 19:39:10.101 | INFO     | flowllm.utils.common_utils:load_env:64 - load env_path=.env
      set FLOW_APP_NAME=ReMe
      
      [1] Cleaning workspace...
      ✓ Workspace 'test_tool_memory_workspace' deleted
      
      [2] Adding mock tool call results...
      
      [ADD] 70 results for 3 tools: database_query, file_processor, web_search
      ✓ Added successfully, created/updated 3 tool memories
      
      [3] Summarizing tool memories...
      
      [SUMMARIZE] web_search,database_query,file_processor
      ✓ Summarized 3 tool memories
      
      ============================================================
      Tool: web_search
      ============================================================
      1. **Core Function**: The web_search tool retrieves authoritative technical documentation, tutorials, and best practices for specific developer-focused queries (e.g., "GraphQL advantages", "OAuth2 flow"). Use it when seeking reliable, in-depth technical information.
      
      2. **Success Patterns**: High-quality results occur with precise, domain-specific queries (e.g., "JWT authentication", "MongoDB schema design") combined with valid parameters like language="en" and filter="technical_docs". These consistently yield 14–19 relevant, authoritative sources.
      
      3. **Common Issues**: Queries fail or return minimal results when: (a) the query is overly generic (e.g., "test query 1"), (b) an unsupported language (e.g., "unknown") is specified, or (c) the request times out (10s cap). Nonsensical queries correctly return zero results but are handled gracefully.
      
      4. **Best Practices**: 
         - Always use specific, technical keywords that reflect real developer tasks or concepts.
         - Validate language parameters (use "en" or other supported codes) and avoid placeholder or invalid values.
      
      ## Statistics
      - **Success Rate**: 75.00%
      - **Average Score**: 0.350
      - **Average Time Cost**: 4.300s
      - **Average Token Cost**: 96.0
      
      ============================================================
      Tool: database_query
      ============================================================
      1. **Core Function**: Executes SQL-like queries on specified tables, returning matching rows up to a user-defined limit. Use when retrieving filtered, ordered, or pattern-matched data from known tables.
      
      2. **Success Patterns**: Queries succeed when using valid table/column names, clear WHERE conditions (e.g., id > N), and reasonable limits. Results are reliable when row counts respect the limit or truthfully reflect available data (even if fewer rows exist).
      
      3. **Common Issues**: Frequent failures occur when: (a) returned rows exceed the specified limit—indicating improper limit enforcement; (b) invalid table/column names cause errors; or (c) results omit actual data rows, returning only metadata.
      
      4. **Best Practices**: 
         - Always verify table and column names match the schema to avoid execution errors. 
         - Treat returned row counts skeptically if they exceed your limit—reformulate or validate the query.
         - For large datasets with LIKE or sorting, expect performance notes; consider indexing suggestions provided in successful responses.
      
      ## Statistics
      - **Success Rate**: 80.00%
      - **Average Score**: 0.650
      - **Average Time Cost**: 2.157s
      - **Average Token Cost**: 55.8
      
      ============================================================
      Tool: file_processor
      ============================================================
      1. **Core Function**: The file_processor reads structured and unstructured files (CSV, JSON, XML, TXT, PDF) and returns metadata—file size and record count—without exposing raw content. Use it to quickly assess file contents before deeper processing.
      
      2. **Success Patterns**: Works reliably on files under ~500KB across all supported formats when valid paths and encodings (e.g., UTF-8) are provided. Consistently returns useful metadata for small-to-medium files in under 3 seconds.
      
      3. **Common Issues**: Fails silently on large files (>500KB–1MB), returning only a size warning without metadata or content—despite marking the call as "successful." Also fails if the file path is invalid, though it correctly reports this error.
      
      4. **Best Practices**: 
         - Pre-check file size; avoid using file_processor on files likely exceeding 500KB. 
         - Always validate file paths before calling to prevent "file not found" errors. 
         - Use UTF-8 encoding for text-based formats unless otherwise required.
      
      ## Statistics
      - **Success Rate**: 83.33%
      - **Average Score**: 0.722
      - **Average Time Cost**: 7.058s
      - **Average Token Cost**: 173.6
      
      [4] Retrieving tool memories...
      
      [RETRIEVE] web_search
      ✓ Retrieved 1 memories
      
      Tool: web_search
      Calls: 30
      ------------------------------------------------------------
      1. **Core Function**: The web_search tool retrieves authoritative technical documentation, tutorials, and best practices for specific developer-focused queries (e.g., "GraphQL advantages", "OAuth2 flow"). Use it when seeking reliable, in-depth technical information.
      
      2. **Success Patterns**: High-quality results occur with precise, domain-specific queries (e.g., "JWT authentication", "MongoDB schema design") combined with valid parameters like language="en" and filter="technical_docs". These consistently yield 14–19 relevant, authoritative sources.
      
      3. **Common Issues**: Queries fail or return minimal results when: (a) the query is overly generic (e.g., "test query 1"), (b) an unsupported language (e.g., "unknown") is specified, or (c) the request times out (10s cap). Nonsensical queries correctly return zero results but are handled gracefully.
      
      4. **Best Practices**: 
         - Always use specific, technical keywords that reflect real developer tasks or concepts.
         - Validate language parameters (use "en" or other supported codes) and avoid placeholder or invalid values.
      
      ## Statistics
      - **Success Rate**: 75.00%
      - **Average Score**: 0.350
      - **Average Time Cost**: 4.300s
      - **Average Token Cost**: 96.0
      
      ✓ Saved to tool_memory.json
      
      [RETRIEVE] database_query
      ✓ Retrieved 1 memories
      
      Tool: database_query
      Calls: 22
      ------------------------------------------------------------
      1. **Core Function**: Executes SQL-like queries on specified tables, returning matching rows up to a user-defined limit. Use when retrieving filtered, ordered, or pattern-matched data from known tables.
      
      2. **Success Patterns**: Queries succeed when using valid table/column names, clear WHERE conditions (e.g., id > N), and reasonable limits. Results are reliable when row counts respect the limit or truthfully reflect available data (even if fewer rows exist).
      
      3. **Common Issues**: Frequent failures occur when: (a) returned rows exceed the specified limit—indicating improper limit enforcement; (b) invalid table/column names cause errors; or (c) results omit actual data rows, returning only metadata.
      
      4. **Best Practices**: 
         - Always verify table and column names match the schema to avoid execution errors. 
         - Treat returned row counts skeptically if they exceed your limit—reformulate or validate the query.
         - For large datasets with LIKE or sorting, expect performance notes; consider indexing suggestions provided in successful responses.
      
      ## Statistics
      - **Success Rate**: 80.00%
      - **Average Score**: 0.650
      - **Average Time Cost**: 2.157s
      - **Average Token Cost**: 55.8
      
      ✓ Saved to tool_memory.json
      
      [RETRIEVE] file_processor
      ✓ Retrieved 1 memories
      
      Tool: file_processor
      Calls: 18
      ------------------------------------------------------------
      1. **Core Function**: The file_processor reads structured and unstructured files (CSV, JSON, XML, TXT, PDF) and returns metadata—file size and record count—without exposing raw content. Use it to quickly assess file contents before deeper processing.
      
      2. **Success Patterns**: Works reliably on files under ~500KB across all supported formats when valid paths and encodings (e.g., UTF-8) are provided. Consistently returns useful metadata for small-to-medium files in under 3 seconds.
      
      3. **Common Issues**: Fails silently on large files (>500KB–1MB), returning only a size warning without metadata or content—despite marking the call as "successful." Also fails if the file path is invalid, though it correctly reports this error.
      
      4. **Best Practices**: 
         - Pre-check file size; avoid using file_processor on files likely exceeding 500KB. 
         - Always validate file paths before calling to prevent "file not found" errors. 
         - Use UTF-8 encoding for text-based formats unless otherwise required.
      
      ## Statistics
      - **Success Rate**: 83.33%
      - **Average Score**: 0.722
      - **Average Time Cost**: 7.058s
      - **Average Token Cost**: 173.6
      
      ✓ Saved to tool_memory.json
      
      [5] Testing memory persistence...
      ✓ Memory dumped to ./
      ✓ Memory loaded from ./
      
      ============================================================
      DEMO COMPLETE ✓
      ============================================================

Advanced practice: AppWorld comparison experiment (Optional)

The ReMe cookbook folder contains a comparison experiment based on benchmarks such as AppWorld. This experiment measures how memory enhancement improves Agent performance.

Warning

This experiment takes a long time to run and consumes many model service tokens. Run this experiment only if necessary.

  • Step 1: Prepare the experiment environment.

    # Create a conda environment
    conda create -p ./appworld-env python==3.12
    conda activate ./appworld-env
    
    # Install dependencies
    pip install -r requirements.txt
    
    # Install AppWorld and download the dataset
    pip install appworld
    appworld install
    appworld download data
  • Step 2: Load the memory library.

    curl -X POST "http://0.0.0.0:8002/vector_store" \
      -H "Content-Type: application/json" \
      -d '{
        "workspace_id": "appworld",
        "action": "load",
        "path": "./docs/library"
      }'
    
  • Step 3: Run the experiment script.

    python run_appworld.py

    This script runs AppWorld tasks on the developer dataset. It compares the Agent's performance in two modes: with ReMe memory (use_memory=True) and without memory.

    Main configuration parameters:

    Parameter

    Description

    Default value

    max_workers

    Number of parallel worker threads

    6

    num_runs

    Number of times each task is repeated

    4

    use_memory

    Specifies whether to enable the ReMe memory library

    -

  • Step 4: Analyze the experiment results.

    python run_exp_statistic.py

    Experiment metrics:

    Metric

    Description

    best@1

    Average performance of a single run

    best@k

    The average of the best performance across k runs. A higher k value indicates a higher potential performance.

    The experiment result files are saved in the ./exp_result/ folder. A summary of the results is exported to the experiment_summary.csv file.