Memory Transfer Planning: LLM-driven Context-Aware Code Adaptation for Robot Manipulation

Tomoyuki Kagaya, Subramanian Lakshmi, Yuxuan Lou, Thong Jing Yuan, Jayashree Karlekar, Sugiri Pranata, Natsuki Murakami, Akira Kinose, Yang YouarXiv 2025 · DOI

Introduction

Large Language Models (LLMs) have demonstrated remarkable capabilities in high-level reasoning and task planning. However, their application to robot manipulation remains challenging due to the "brittleness" of generated code when faced with environmental shifts. Most current systems rely on fixed prompts or extensive environment-specific training, making them difficult to deploy in new settings—such as moving from a simulator to a real-world laboratory with different coordinate systems, API conventions, or physical constraints.

Memory Transfer Planning (MTP) addresses this bottleneck by allowing robots to leverage a library of successful past executions. Instead of treating each task as a zero-shot problem, MTP retrieves procedural knowledge from a "code memory" and adapts it to the current context. This framework significantly improves success rates across diverse benchmarks and physical hardware without requiring model retraining.

The MTP Framework

The MTP framework operates through a continuous loop of generation, retrieval, and adaptation. When a robot is tasked with a new instruction, the system first attempts to generate a plan using the standard environment API. If this initial attempt fails, the MTP pipeline is triggered.

Overview of the MTP framework showing the flow from source environment memory to target environment re-planning.

1. Code Generation and Retrieval

The process begins with an LLM (e.g., GPT-4o-mini) generating initial Python control code. Upon failure, the system queries a database of successful task executions. Using sentence embeddings, MTP identifies the most semantically similar tasks from its memory based on the natural language instruction. For instance, if the robot fails to "open a drawer," it might retrieve a successful "open cabinet" sequence from a different environment.

2. Context-Aware Memory Adaptation

The core innovation of MTP is its adaptation step. Simply providing the LLM with old code from a different environment often introduces noise or incompatible parameters. MTP performs a "translation" where the LLM is prompted to rewrite the retrieved source code to match the target environment's style, units, and API.

The prompt structure used for context-aware memory adaptation, translating source code into target-compatible instructions.

This adaptation ensures that procedural logic—the sequence of fundamental actions—is preserved while specific implementation details are updated for the new hardware or simulator.

3. Re-planning

The adapted code serves as a high-quality reference for a second planning attempt. By seeing how a similar task was successfully solved and adapted, the LLM can generate a corrected plan that overcomes the initial failure.

Experimental Evaluation

The researchers evaluated MTP across three distinct platforms: RLBench, CALVIN, and a physical UR5 industrial arm.

  • RLBench: In this tabletop manipulation benchmark, MTP increased success rates from 39.3% (using the VoxPoser baseline) to 64.4%.
  • CALVIN: For long-horizon tasks involving multiple objects and sliders, success rates improved from 52.0% to 67.3%.
  • Physical Robot (UR5): The most significant gains were observed in real-world testing. The success rate for complex tasks rose from 30% to 75%, demonstrating MTP's effectiveness as a sim-to-real bridge.

An ablation study highlighted the necessity of the adaptation step. When the system attempted to use retrieved code without context-aware translation, success rates on RLBench dropped from 64.4% to 49.3%. This confirms that environment-specific "noise" in raw memory can actively hinder performance if not properly filtered.

Discussion and Future Work

MTP demonstrates that procedural knowledge is highly transferable across robotic platforms. By treating successful code as a reusable asset, the framework reduces the need for manual prompt engineering and extensive data collection.

However, several areas for improvement remain. The current memory is largely static; a dynamic system that autonomously updates its library during deployment would enhance scalability. Additionally, the framework currently relies on textual descriptions of failures. Integrating direct visual feedback, such as point clouds or RGB-D images, into the re-planning loop could provide more granular error correction. Finally, the multi-step LLM pipeline introduces computational latency, which may need optimization for high-speed real-time applications.

Summary updated

BibTeX
@misc{kagaya2025memory,
  author = {Tomoyuki Kagaya and Subramanian Lakshmi and Yuxuan Lou and Thong Jing Yuan and Jayashree Karlekar and Sugiri Pranata and Natsuki Murakami and Akira Kinose and Yang You},
  title = {{Memory Transfer Planning: LLM-driven Context-Aware Code Adaptation for Robot Manipulation}},
  year = {2025},
  eprint = {2509.24160},
  archivePrefix = {arXiv},
  url = {https://arxiv.org/abs/2509.24160},
}
Figure