Memory-as-Action: DCPO Training Framework

November 19, 2025 ยท View on GitHub

License

Paper: Memory as Action: Autonomous Context Curation for Long-Horizon Agentic Tasks

A reinforcement learning training framework based on verl 0.5.0, implementing the Dynamic Context Policy Optimization (DCPO) algorithm for training agents that can autonomously manage context.

๐Ÿ“– Introduction

This project provides a complete training framework supporting:

  • Autonomous context management by agents (via memory editing tools)
  • DCPO algorithm for reinforcement learning training
  • Multi-turn conversations and tool calling
  • Distributed training (with Ray support)

โœจ Core Features

  • DCPO Training: Reinforcement learning algorithm supporting trajectory segmentation and advantage estimation
  • Memory Management Tools: Agents can actively edit context through tool calls
  • Multi-turn Conversations: Support for long-horizon multi-turn interactions
  • Tool Integration: Built-in search tools and context pruning tools

๐Ÿ—๏ธ Project Structure

rl_train/
โ”œโ”€โ”€ DCPO/                          # DCPO related configs and scripts
โ”‚   โ”œโ”€โ”€ config/                    # Training configuration files
โ”‚   โ”‚   โ”œโ”€โ”€ mem_agent_loop_config.yaml
โ”‚   โ”‚   โ””โ”€โ”€ mem_search_tool_config_single.yaml
โ”‚   โ”œโ”€โ”€ data/                      # Training and validation data
โ”‚   โ”œโ”€โ”€ scripts/                   # Training scripts
โ”‚   โ”‚   โ”œโ”€โ”€ run_dcpo_7B.sh
โ”‚   โ”‚   โ”œโ”€โ”€ run_dcpo_14B_single.sh
โ”‚   โ”‚   โ””โ”€โ”€ reward_service.sh
โ”‚   โ””โ”€โ”€ tool_service/              # Tool service implementations
โ”‚       โ”œโ”€โ”€ search_search_services.py
โ”‚       โ””โ”€โ”€ search_tool_single.py
โ”œโ”€โ”€ verl/                          # Core training framework
โ”‚   โ”œโ”€โ”€ experimental/
โ”‚   โ”‚   โ””โ”€โ”€ agent_loop/            # Agent loop implementations
โ”‚   โ”‚       โ”œโ”€โ”€ mem_agent_loop.py  # MemAct agent loop
โ”‚   โ”‚       โ”œโ”€โ”€ agent_loop.py      # Base agent loop
โ”‚   โ”‚       โ””โ”€โ”€ tool_parser.py     # Tool parser
โ”‚   โ”œโ”€โ”€ trainer/                   # Trainers
โ”‚   โ”‚   โ”œโ”€โ”€ main_ppo.py            # PPO main training entry
โ”‚   โ”‚   โ””โ”€โ”€ ppo/
โ”‚   โ”‚       โ”œโ”€โ”€ core_algos.py      # Core algorithms (including DCPO)
โ”‚   โ”‚       โ””โ”€โ”€ ray_trainer.py     # Ray distributed training
โ”‚   โ”œโ”€โ”€ tools/                     # Tool implementations
โ”‚   โ”‚   โ”œโ”€โ”€ base_tool.py
โ”‚   โ”‚   โ””โ”€โ”€ search_tool.py
โ”‚   โ””โ”€โ”€ utils/                     # Utility functions
โ””โ”€โ”€ cold_start/                    # Cold start related
    โ”œโ”€โ”€ data/
    โ””โ”€โ”€ scripts/

๐Ÿš€ Quick Start

Requirements

  • verl 0.5.0
  • Multi-GPU environment (recommended: 8x H100 or equivalent)

Installation

  1. Install verl 0.5.0
pip install verl==0.5.0
  1. Install additional dependencies
pip install shortuuid uuid
pip install numpy==1.26.4

Data

Data files should be placed in */data/ directories.

Training Configuration

  1. Modify training scripts (e.g., DCPO/scripts/run_dcpo_7B.sh):

    • Set model path: model_path=/path/to/your/model
    • Set data paths: train_files and test_files
    • Set log directory: logdir
    • Configure GPU count and other training parameters
  2. Configure tools (if needed): Edit DCPO/config/mem_search_tool_config_single.yaml to configure tool service addresses and parameters

Running Training

Before RL training, you need to start the reward service and retrieval service in advance.

๐Ÿ“ Configuration

Training Script Parameters

Main configurations are set in training scripts, overriding defaults via Hydra:

python3 -m verl.trainer.main_ppo \
    --config-path="$CONFIG_PATH" \
    --config-name='mem_agent_loop_config' \
    algorithm.adv_estimator=dcpo \          # Use DCPO algorithm
    data.train_batch_size=128 \
    data.max_prompt_length=4096 \          # Max prompt length
    data.max_response_length=20480 \       # Max response length
    actor_rollout_ref.rollout.multi_turn.max_assistant_turns=40 \
    actor_rollout_ref.rollout.n=12 \       # Number of segments per prompt used for training
    actor_rollout_ref.rollout.actual_n=8 \ # Number of trajectories generated per prompt
    ...

Configuration Files

  • DCPO/config/mem_agent_loop_config.yaml: Main training configuration
  • DCPO/config/mem_search_tool_config_single.yaml: Tool configuration
    • Search tool: Configure retrieval service URL and parameters
    • Context pruning tool: For managing conversation history

Key Parameters

  • algorithm.adv_estimator=dcpo: Must be set to dcpo to use DCPO algorithm
  • actor_rollout_ref.rollout.actual_n: DCPO sampling strategy, sample n segments from actual_n trajectories for training
  • actor_rollout_ref.rollout.multi_turn.max_assistant_turns: Maximum conversation turns
  • actor_rollout_ref.rollout.multi_turn.tool_config_path: Tool configuration file path

๐Ÿ“„ Citation

If you use this project, please cite our paper:

@article{zhang2025memory,
  title={Memory as Action: Autonomous Context Curation for Long-Horizon Agentic Tasks},
  author={Zhang, Yuxiang and Shu, Jiangming and Ma, Ye and Lin, Xueyuan and Wu, Shangxi and Sang, Jitao},
  journal={arXiv preprint arXiv:2510.12635},
  year={2025}
}

๐Ÿ“„ License

This project is licensed under the MIT License. See the LICENSE file for details.

๐Ÿ“ง Contact

For questions or suggestions, please contact us