RAP: Retrieval-Augmented Planning with Contextual Memory for Multimodal LLM Agents

Tomoyuki Kagaya, Thong Jing Yuan, Yuxuan Lou, Jayashree Karlekar, Sugiri Pranata, Akira Kinose, Koki Oguri, Felix Wick, Yang You

TL;DR

Retrieval-Augmented Planning (RAP) is an agent framework that equips Large Language Models (LLMs) and Vision-Language Models (VLMs) with dynamic, context-aware episodic memory. Instead of planning in a vacuum or relying solely on trial-and-error reflection within a single episode, RAP dynamically retrieves relevant trajectory snippets from past successful tasks based on the current context, state, and goals. Across both text-based reasoning (ALFWorld, WebShop) and embodied robotic manipulation (Franka Kitchen, Meta-World), RAP achieves state-of-the-art performance and substantial gains over baseline prompting methods like ReAct.

What Problem Does This Paper Address?

While LLM agents can interleave reasoning and action (e.g., via ReAct), they struggle to draw upon past experiences when tackling new problems. Existing memory-augmented or reflection methods (such as Reflexion or ADaPT) primarily evaluate failures within a single trajectory or require explicit textual post-hoc self-reflection. They do not provide a general mechanism for agents to spontaneously recall relevant sub-trajectories from prior successful runs across different tasks. Moreover, existing memory retrieval techniques focus almost exclusively on pure text, leaving multimodal and robotic embodied agents without a straightforward way to recall visual observations and physical action sequences.

Methods

RAP introduces an episodic retrieval loop divided into four specialized modules:

  1. Memory: Stores structured logs of prior successful task executions: task description $T$, initial overarching plan $p$, and step-by-step trajectories $\tau = (\text{plans } \vec{p}', \text{actions } \vec{\alpha}, \text{observations } \vec{o})$. Observations can be text strings or first-person camera images.
  2. Reasoner: Generates the high-level plan, decomposes it into fine-grained action plans ("think" steps), and generates dynamic retrieval keys conditioned on what the agent needs at that specific moment (e.g., "search mug" or "action clean").
  3. Retriever: Searches the memory using a weighted combination of cosine similarities: $$\text{Score}(S_0, L_i) = w_t \cdot \text{sim}(T_0, T_{L_i}) + w_p \cdot \text{sim}(p_0, p_{L_i}) + w_k \cdot \text{sim}(k_0, \tau_{L_i})$$ Here, text embeddings are calculated via Sentence-BERT, and visual observations via CLIP. Rather than retrieving entire episodes—which introduces prompt clutter and noise—the Retriever extracts a localized temporal window centered around the most relevant action or observation.

  4. Executor: Consumes the retrieved memory snippets via in-context learning (ICL) alongside the current trajectory to predict the immediate next action. For embodied robotics tasks, high-level action outputs from a VLM (such as LLaVA or CogVLM) are translated into continuous control actions via an MLP policy network trained on few-shot demonstrations.

       ┌────────────────────────┐
       │      Current Task      │
       └───────────┬────────────┘
                   ▼
             ┌───────────┐
             │ Reasoner  │ ──── (Retrieval Key) ───┐
             └─────┬─────┘                         ▼
                   │ Action Plan             ┌───────────┐     ┌──────────┐
                   │                         │ Retriever │ ◄── │  Memory  │
                   ▼                         └─────┬─────┘     └──────────┘
             ┌───────────┐                         │
             │ Executor  │ ◄── (Relevant Snippet) ─┘
             └─────┬─────┘
                   ▼
         [ Executable Action ]

Datasets

The authors evaluated RAP on four distinct benchmarks:

  • Textual Environments:
  • ALFWorld: 134 unseen multi-step household decision-making games across six task types (Pick, Clean, Heat, Cool, Look, Pick2).
  • WebShop: An e-commerce navigation environment comprising 1.18M real Amazon products, evaluated on 100 search/purchase instructions.
  • Multimodal / Embodied Robotics:
  • Franka Kitchen: 5 compound manipulation subtasks (e.g., opening cabinets, turning burner knobs, turning on lights) viewed from two camera angles.
  • Meta-World: 5 distinct robotic manipulation tasks (e.g., peg assembly, button pressing, hammering).

Key Insights and Ideas

  • Dynamic Retrieval Keys Beat Static Lookups: Instead of retrieving similar tasks only at the start, the Reasoner dynamically generates keys at intermediate steps (e.g., switching between finding an object and manipulating it). This enables the agent to pull entirely different precedents mid-trajectory.
  • Windowed Snippets Reduce Noise: Passing an entire historical episode introduces distracting context. Supplying only a short window (e.g., 3–8 steps) centered on the most similar action/state leads to cleaner analogical reasoning by the LLM.
  • Cross-Model Memory Transfer: Memories logged by a stronger model (GPT-3.5) directly benefit weaker open-source models (Llama-2-13B), demonstrating that successful trajectory logs are model-agnostic demonstrations.
  • Direct Visual Retrieval: In ALFWorld multimodal settings, retrieving memories using direct visual embeddings (CLIP image features) outperformed text-only descriptions, indicating that visual states carry richer situational context.

Key Results

  • ALFWorld:
  • With GPT-3.5, RAP reached 85.8% success (and 91.0% when seeded with training set logs), outperforming ReAct (52.2%), Reflexion (74.6%), and ADaPT (71.6%).
  • With GPT-4, RAP achieved 94.8% (vs. ReAct's 85.8%).
  • On open-source Llama-2-13B, RAP reached 53.0% compared to ReAct's 36.6%.
  • WebShop:
  • RAP (GPT-3.5) achieved an overall score of 76.1% and a 48.0% success rate, outperforming ReAct (61.8% score, 35.0% success rate).
  • Embodied Robotic Benchmarks:
  • Franka Kitchen: Adding RAP boosted LLaVA's success rate from 43.4% to 61.6% (+18.2%) and CogVLM's from 44.2% to 56.9%.
  • Meta-World: LLaVA jumped from 65.4% to 79.2% (+13.8%), and CogVLM climbed from 61.5% to 68.8%.

Limitations and Future Work

  • Lifelong Memory Organization: As an agent operates over long periods, the memory pool grows substantially; the current setup lacks hierarchical pruning, clustering, or forgetting mechanisms to maintain low search latency and high retrieval precision.
  • Modalities Restricted to Static Images: Multimodal perception currently relies on fixed-camera single-frame observations; incorporating continuous video feeds or audio feedback remains an open challenge.
  • Dependence on Demonstration Quality: The embodied policy execution still relies on a few-shot demonstration-trained MLP; poor low-level policies can bottle up high-level planning improvements.

Summary updated

BibTeX
@inproceedings{kagaya2024rap,
  author = {Tomoyuki Kagaya and Thong Jing Yuan and Yuxuan Lou and Jayashree Karlekar and Sugiri Pranata and Akira Kinose and Koki Oguri and Felix Wick and Yang You},
  title = {{RAP: Retrieval-Augmented Planning with Contextual Memory for Multimodal LLM Agents}},
  booktitle = {OWA @ NeurIPS},
  year = {2024},
  url = {https://openreview.net/forum?id=Xf49Dpxuox},
}
Figure