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.
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)
- 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
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/
- verl 0.5.0
- Multi-GPU environment (recommended: 8x H100 or equivalent)
- Install verl 0.5.0
pip install verl==0.5.0- Install additional dependencies
pip install shortuuid uuid
pip install numpy==1.26.4Data files should be placed in */data/ directories.
-
Modify training scripts (e.g.,
DCPO/scripts/run_dcpo_7B.sh):- Set model path:
model_path=/path/to/your/model - Set data paths:
train_filesandtest_files - Set log directory:
logdir - Configure GPU count and other training parameters
- Set model path:
-
Configure tools (if needed): Edit
DCPO/config/mem_search_tool_config_single.yamlto configure tool service addresses and parameters
Before RL training, you need to start the reward service and retrieval service in advance.
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
...DCPO/config/mem_agent_loop_config.yaml: Main training configurationDCPO/config/mem_search_tool_config_single.yaml: Tool configuration- Search tool: Configure retrieval service URL and parameters
- Context pruning tool: For managing conversation history
algorithm.adv_estimator=dcpo: Must be set todcpoto use DCPO algorithmactor_rollout_ref.rollout.actual_n: DCPO sampling strategy, samplensegments fromactual_ntrajectories for trainingactor_rollout_ref.rollout.multi_turn.max_assistant_turns: Maximum conversation turnsactor_rollout_ref.rollout.multi_turn.tool_config_path: Tool configuration file path
- verl: https://github.com/volcengine/verl (version 0.5.0)
- Training is based on verl's PPO framework, using DCPO as the advantage estimator
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}
}This project is licensed under the MIT License. See the LICENSE file for details.
For questions or suggestions, please contact us