Shared Selective Persistent Memory: Solving Context Forgetting in Multi-Turn Tool Calls for Agentic LLMs
Addressing the context reset and historical redundancy challenges that agentic large language models face during multi-turn tool calls, this paper proposes a shared selective persistent memory architecture. The architecture intelligently identifies and preserves four categories of high-value context—task specifications, data patterns, tool configurations, and output constraints—while filtering out session-specific reasoning traces, effectively resolving the token inefficiency and degraded generation quality caused by traditional full-history persistence. Experiments demonstrate that the mechanism achieves a 96% task completion rate across three enterprise scenarios, significantly outperforming no-memory (79%) and full-history-memory (71%) baselines. Additionally, a zero-token data refresh mechanism eliminates the overhead of redundant LLM calls, reducing task time by 14× and cutting per-turn token costs by 97×. This innovation not only enhances agent collaboration and reusability but also provides an efficient memory management paradigm for industrial-grade AI applications.
Background and Context
The deployment of agentic large language models (LLMs) in complex, multi-turn environments has exposed a critical architectural flaw: the inability to maintain high-fidelity context across distinct operational sessions. When these systems engage in extended workflows, such as generating code or executing intricate business logic, they frequently rely on tool calls to interact with external APIs and databases. However, standard implementations typically treat each new session as a blank slate, discarding the accumulated configuration choices, domain-specific constraints, and tool usage patterns established in previous interactions. This context reset forces the model to re-learn basic parameters for every new task, creating a significant bottleneck in operational efficiency. While a naive solution might suggest persisting the entire conversation history to prevent information loss, this approach introduces severe token inefficiencies and injects substantial noise into the context window, ultimately degrading the accuracy of the model's outputs.
To address this fundamental dilemma, researchers have proposed a novel architecture termed "Shared Selective Persistent Memory." This framework moves beyond simple history logging by intelligently distinguishing between high-value, reusable context and transient, session-specific reasoning traces. The core innovation lies in its ability to identify and preserve four specific categories of information that retain utility across different tasks: task specifications, data patterns, tool configurations, and output constraints. By filtering out ephemeral data such as intermediate variable states or temporary reasoning steps that lack generalizability, the system ensures that the memory bank remains dense with actionable intelligence rather than diluted by irrelevant noise. This selective approach not only resolves the token inefficiency associated with full-history persistence but also establishes a foundation for collaborative reuse among different users and roles within an enterprise environment.
Deep Analysis
The technical implementation of the Shared Selective Persistent Memory architecture relies on a sophisticated classification and encapsulation strategy designed to maximize information density. The system first analyzes multi-turn interactions to categorize information into persistent units and transient states. High-value context, including detailed task specifications, underlying data schema definitions, external tool API configurations, and strict output format constraints, is extracted and stored as structured memory units. Conversely, session-specific artifacts, such as intermediate reasoning steps or temporary variables, are explicitly excluded from storage. This differentiation prevents the attention mechanism of the LLM from being distracted by irrelevant details, thereby preserving the model's focus on the core objectives of the current task. The memory module is further encapsulated within isolated workspaces that support role-based access control, ensuring that shared knowledge can be utilized securely without compromising data privacy or system integrity.
Experimental validation of this architecture was conducted across three distinct enterprise-grade scenarios, comparing the proposed selective memory approach against two baselines: a no-memory strategy and a full-history memory strategy. The results demonstrated a clear superiority for the selective method, achieving a task completion rate of 96%. In stark contrast, the no-memory baseline completed only 79% of tasks, while the full-history memory strategy performed even worse, with a completion rate of just 71%. This counterintuitive finding regarding the full-history baseline confirms that indiscriminate retention of conversation history introduces significant contextual noise that actively hinders model performance. The selective memory mechanism, by curating only the most relevant and reusable information, effectively mitigates this degradation, allowing the agent to operate with higher precision and reliability in complex, multi-step workflows.
Beyond accuracy, the architecture introduces a "zero-token data refresh" mechanism that fundamentally alters the cost structure of agentic operations. By decoupling the generated program code from the runtime data, the system can update execution contexts without invoking the LLM to regenerate instructions. This separation eliminates the overhead of redundant LLM calls during data updates, reducing the time required for repetitive tasks by a factor of 14. Furthermore, the use of summarized data representations instead of raw data injection has led to a dramatic reduction in computational costs. The per-turn token cost for the selective memory system is 97 times lower than that of direct raw data injection methods. These efficiency gains were further corroborated by replication experiments on four public datasets, where the zero-token refresh mechanism succeeded in all 12 trials, demonstrating robust generalization across varying data distributions.
Industry Impact
The implications of this research extend significantly into the realm of industrial AI application development, offering a scalable path to resolving the "forgetting" problem that plagues many autonomous agent systems. By proving that selective memory outperforms full-history persistence in both accuracy and efficiency, the study provides a compelling argument for enterprises to overhaul their context management strategies. The ability to share and reuse memory units across different users and roles fosters a collaborative ecosystem where agents can build upon the accumulated knowledge of their predecessors. This capability is particularly valuable in enterprise settings where consistent adherence to data schemas, API protocols, and output standards is critical for operational stability. The modular design of the memory system allows for easier maintenance and integration into existing workflows, reducing the friction associated with deploying advanced agentic capabilities.
Moreover, the substantial reduction in token costs and task execution times addresses one of the primary barriers to the widespread adoption of LLM-based agents in cost-sensitive industries. The 97-fold reduction in per-turn token costs makes it economically viable to deploy agents for tasks that require frequent, low-level interactions with data sources, which were previously prohibitively expensive. The 14-fold improvement in task time for repetitive updates further enhances the appeal of these systems for automation workflows. These efficiency metrics suggest that the Shared Selective Persistent Memory architecture can serve as a foundational component for next-generation industrial AI platforms, enabling the creation of more responsive, reliable, and cost-effective autonomous systems. The research also highlights the importance of structured memory management as a key differentiator in the competitive landscape of AI agent development.
Outlook
Looking forward, the Shared Selective Persistent Memory architecture opens new avenues for research into long-term memory management and cross-session knowledge transfer. The current framework establishes a robust baseline for selective retention, but future iterations may explore more dynamic mechanisms for memory prioritization and decay, allowing agents to adapt their memory banks based on changing task requirements or user preferences. Additionally, the potential for personalized agent customization is vast; by leveraging shared memory units, systems could be tailored to individual user styles and historical preferences without compromising the core operational logic. As LLMs continue to penetrate deeper into vertical industries, the ability to manage long-term context efficiently will become a decisive factor in system performance. The selective approach presented here offers a highly relevant solution to this emerging challenge, setting a new standard for how agentic systems should handle information retention and retrieval in complex, multi-turn environments.
The success of the zero-token data refresh mechanism also points toward a future where the boundary between code generation and data execution is more fluid. By treating data updates as a separate concern from logical reasoning, developers can create more modular and resilient agentic applications. This decoupling not only improves performance but also enhances security and auditability, as the reasoning process remains distinct from the data it manipulates. As the technology matures, we can expect to see broader adoption of such selective memory paradigms across various sectors, from software development automation to complex financial analysis. The research underscores the necessity of moving beyond naive context persistence toward intelligent, curated memory systems that prioritize relevance and reuse, ultimately paving the way for more capable and efficient AI agents.