G-Memory: Tracing Hierarchical Memory for Multi-Agent Systems

June 10, 2025 ยท View on GitHub

๐Ÿ‘‹ Introduction

This repo is the official implementation of G-Memory: Tracing Hierarchical Memory for Multi-Agent Systems.

Our method, G-Memory, empowers multi-agent systems with a hierarchical memory architecture that continuously evolves through interaction. Inspired by organizational memory theory, G-Memory captures generalizable insights and agent-specific collaboration trajectories across tasks using a structured graph-based design. When a new task arrives, it retrieves relevant past experiences and distilled knowledge to inform agent behavior and coordination. As agents complete tasks, G-Memory updates its memory hierarchy with new interactions, enabling teams to adapt and improve over time.

alt text

๐ŸŒŽ Setup

conda create -n GMemory python=3.12
conda activate GMemory
pip install -r requirements.txt

๐Ÿš€ Quick Start

๐ŸŒณ Environments

Please download the ALFWorld, PDDL, FEVER datasets and place it in the data folder.

The file structure should be organized as follows:

data
โ””โ”€โ”€ alfworld
    โ””โ”€โ”€ alfworld_tasks_suffix.json
โ””โ”€โ”€ pddl
    โ””โ”€โ”€ test.json
โ””โ”€โ”€ fever
    โ””โ”€โ”€ fever_dev.jsonl

๐Ÿ”‘ Add API keys in template.env and change its name to .env

OPENAI_API_BASE = "" # the BASE_URL of OpenAI LLM backend
OPENAI_API_KEY = ""  # for OpenAI LLM backend

๐Ÿ”Ž Choices Overview

  • Available memories: Empty, ChatDev, MetaGPT, Voyager, Generative, MemoryBank, G-Memory
  • Available MAS: AutoGen, DyLAN, MacNet

โ–ถ๏ธ How to Run

  • Option 1: Run with Shell Script. Simply execute the following script:
    ./run_mas.sh
    
  • Option 2: Run with Python Command. You can also launch specific tasks via command-line:
    python tasks/run.py --task alfworld --reasoning io --mas_memory g-memory --max_trials 30 --mas_type autogen --model <your model here>
    python tasks/run.py --task pddl --reasoning io --mas_memory g-memory --max_trials 30 --mas_type autogen --model <your model here>
    python tasks/run.py --task fever --reasoning io --mas_memory g-memory --mas_trials 15 --mas_type autogen --model <your model here>
    

๐Ÿซก Citation

If you find this repository helpful, a citation to our paper would be greatly appreciated:

@article{zhang2025g-memory,
  title={G-Memory: Tracing Hierarchical Memory for Multi-Agent Systems},
  author={Zhang, Guibin and Fu, Muxin and Wan, Guancheng and Yu, Miao and Wang, Kun and Yan, Shuicheng},
  journal={arXiv preprint arXiv:2506.07398},
  year={2025}
}

๐Ÿ™ Acknowledgement

  • We sincerely thank ExpeL for providing their prompt designs.
  • We also extend our heartfelt thanks to AgentSquare for their dataset environments and baseline implementations.