An Efficient Context-Dependent Memory Framework for LLM -Centric Agents (2025)

Abstract: In human cognitive memory psychology, the context-dependent effect helps retrieve key memory cues essential for recalling relevant knowledge in problem-solving. Inspired by this, we introduce the context-dependent memory framework (CDMem), an efficient architecture miming human memory processes through multistage encoding, context-aware storage, and retrieval strategies for LLM-centric agents. We propose multistage memory encoding strategies for acquiring high-quality multilevel knowledge: expert encoding compresses raw trajectories from a domain-expert perspective, short-term encoding consolidates experiences from current tasks, and long-term encoding reflects insights from past tasks. For memory storage and retrieval, we design a graph-structured, context-dependent indexing mechanism that allows agents to efficiently and accurately recall the most relevant multilevel knowledge tailored to the current task and environmental context. Furthermore, the proposed CDMem framework is an online learning architecture, enabling agents to efficiently learn and update memory while adapting to novel environments and tasks in real-world applications. We conducted extensive experiments on two interactive decision-making benchmarks in the navigation and manipulation domain, ALFWorld and ScienceWorld. Using GPT-4o-mini, our method surpasses state-of-the-art online LLM-centric approaches, achieving success rates of 85.8% and 56.0%, respectively. We hope this work will serve as a valuable reference for the academic and industrial communities in advancing agent-based applications.

## introduction memory plays a fundamental role in human cognition and brain psychology @xcite @xcite , serving as a critical component for learning, storing, and retrieving knowledge, which is equally vital for intelligent agents. llm-centric agents have achieved notable success in many decision-making tasks. some studies have explored the synergy of reasoning traces and specific actions in an interleaved way to improve decision performance @xcite . @xcite further introduced a reflection mechanism, enabling agents to summarize experiences from past trajectories and apply them to subsequent trials or tasks. recently, some llm-centric agents have been designed with memory modules to facilitate information storage and retrieval by organizing environmental knowledge into categories or generating state-aware guidelines @xcite . memory storage is often inefficient, hindering quick access and selective retrieval, which results in slower and less accurate decisions @xcite . these methods often struggle to store and retrieve complex information effectively, especially in dynamically changing contexts, preventing agents from leveraging relevant information. the human brain encodes, stores, and retrieves memories in a context-dependent manner, associating them with specific environments or tasks to quickly identify key cues and activate relevant memory @xcite . inspired by this, we propose the context-dependent memory framework (cdmem), an efficient architecture miming human memory processes through multistage encoding, context-aware storage, and retrieval strategies for llm-centric agents. we introduce a multistage memory encoding strategy to learn high-quality, multilevel knowledge. first, expert encoding compresses raw trajectories from a domain-expert perspective, mimicking how human experts effectively organize and summarize information after completing a trial. next, short-term encoding consolidates successes and failures from recent trials within the current task. finally, long-term encoding integrates insights from past tasks and updates memory indexes to maintain relevance and accuracy. furthermore, as illustrated in figure 1 , we propose a contextdependent storage indexing mechanism that structures multilevel knowledge within a graph. during retrieval, the agent identifies the current task and environment types and then utilizes the key cues to accurately access relevant exemplars, task experiences, and insights. this precise retrieval process enhances the llm-centric agent's ability to address and solve the current task effectively. additionally, the proposed cdmem is an online learning framework that enables agents to efficiently learn and update memory while adapting to novel environments and tasks in real-world applications. to summarize, our contributions are as follows: ## method when humans perform tasks in a specific environment, they use environment-and task-specific cues to retrieve relevant memories efficiently. after completing a task, they organize and consolidate these memories for future use. inspired by this process, we propose the context-dependent memory (cd-mem) framework, which includes three key components: memory encoding, context-dependent memory storage, and context-dependent memory retrieval. this framework efficiently retrieves relevant exemplars, experiences, and insights based on the current environment and task instructions. memory encoding uses a novel multistage memory learning strategy, while memory storage and retrieval rely on a context-dependent indexing structure. detailed method descriptions with pseudo code are provided in the appendix. ## conclusion we introduce cdmem, an efficient online memory framework for llm-centric agents inspired by human memory mechanisms and designed for domain-specific industrial applications. our approach incorporates a multi-stage memory learning method-expert encoding, short-term memory encoding, and long-term memory encoding-to effectively capture and organize knowledge from past tasks. we also introduce a context-dependent graph-based indexing structure that allows agents to retrieve relevant knowledge efficiently. we demonstrate that cdmem significantly outperforms state-of-the-art methods through extensive experiments, achieving notable performance improvements. 1066 figure 11: our prompt template for long-term memory encoding of environmental insights.