Memento: Fine-Tune LLM Agents Without Fine-Tuning LLMs – The Memory-Based Revolution in AI Continual Learning + Video

Listen to this Post

Featured Image

Introduction:

The artificial intelligence community has long grappled with a fundamental paradox: how to make Large Language Model (LLM) agents continuously learn and adapt without the prohibitive cost of parameter updates. Traditional approaches either rely on rigid, handcrafted workflows that cannot evolve post-deployment or demand computationally expensive fine-tuning that can cost tens of thousands of dollars and weeks of GPU time. Enter Memento – a groundbreaking memory-based continual learning framework developed by UCL AI Centre and Huawei Noah’s Ark Lab that enables LLM agents to learn from experience over time without ever touching model weights. By reframing continual learning as a memory-augmented Markov Decision Process (M-MDP) with case-based reasoning at its core, Memento achieves state-of-the-art performance on demanding benchmarks while reducing adaptation costs by up to 90%.

Learning Objectives:

  • Understand the architectural principles behind Memento’s planner-executor framework and how case-based reasoning enables continual learning without gradient updates
  • Master the practical implementation of Memento’s memory-augmented decision process, including installation, configuration, and integration with existing LLM workflows
  • Learn to leverage Memento’s comprehensive tool ecosystem through the Model Context Protocol (MCP) for web search, code execution, document processing, and multimodal analysis

You Should Know:

1. Understanding Memento’s Core Architecture: The Planner–Executor Loop

Memento’s architecture fundamentally reimagines how LLM agents process tasks through a sophisticated two-stage planner–executor loop. At its heart lies a Case Bank – an episodic memory system that stores past trajectories including tasks, step sequences, tool usage, and outcomes. When a new task arrives, the system doesn’t start from zero; instead, it retrieves relevant past experiences to guide its decision-making.

The Meta-Planner (typically powered by GPT-4.1 or similar LLMs) decomposes high-level user queries into executable subtasks. It retrieves relevant cases from the Case Bank using either non-parametric nearest-1eighbour matching or a parametric neural case-selection policy trained with soft Q-learning. The retrieval policy, optimized through maximum-entropy reinforcement learning, balances reward maximization with exploration diversity.

The Executor then runs each subtask as an MCP client, orchestrating a unified tool ecosystem that includes web search, code execution, document processing, image and video analysis, and more. After execution, outcomes – whether successful or failed – are logged back into the Case Bank, creating a continuous read-write learning loop.

This approach formalizes agent behavior as a Memory-augmented Markov Decision Process (M-MDP), where the agent’s decision at each step depends not only on the current state but also on retrieved cases from memory. The retrieval mechanism itself improves over time through soft temporal-difference learning, with transitions stored in a replay buffer and network parameters updated to minimize TD error – all without ever modifying the underlying LLM’s parameters.

2. Installation and Environment Setup

To begin working with Memento, you’ll need to set up the framework in your development environment. The official codebase is available on GitHub at `https://github.com/Memento-Teams/Memento`.

Prerequisites:

  • Python 3.8 or higher
  • Conda (recommended for environment management)
  • API keys for LLM providers (OpenAI, Anthropic, or local models via vLLM)

Step-by-Step Installation:

 Clone the repository
git clone https://github.com/Memento-Teams/Memento.git
cd Memento

Create and activate a Conda environment
conda create -1 memento python=3.8
conda activate memento

Install dependencies
pip install -r requirements.txt

Set up environment variables
export OPENAI_API_KEY="your-api-key-here"
 Or for local deployment:
 export VLLM_API_BASE="http://localhost:8000/v1"

For local LLM deployment as the executor, Memento supports vLLM integration. You can deploy a local model using:

 Start vLLM server (example with Llama 3)
python -m vllm.entrypoints.openai.api_server \
--model meta-llama/Meta-Llama-3-8B-Instruct \
--port 8000

Then configure Memento to use the local endpoint by modifying the executor configuration in client/agent_local_server.py.

3. Configuring MCP Tools for Unified Tool Access

Memento’s power lies in its unified tool ecosystem accessible through the Model Context Protocol (MCP). The framework includes a comprehensive suite of MCP servers providing 24+ memory tools organized by category.

Available MCP Tool Categories:

  • Core Observations: Memory management and state tracking
  • Information Retrieval: Search engines and web crawlers
  • Multimodal Processing: Video and image analysis
  • Document Processing: Various file format handling
  • Code Execution: Secure code interpretation

Configuring the SerpAPI Search Tool:

Memento provides a SerpAPI MCP tool to avoid running a local search Docker container:

 In your Memento configuration
from memento.tools import SerpAPITool

search_tool = SerpAPITool(
api_key="your-serpapi-key",
num_results=10
)

Use in executor
results = search_tool.search("your query here")

Setting Up the Web Crawler MCP:

For more comprehensive web crawling with query-aware content compression:

 Configure the crawler MCP server
 server/ai_crawler.py provides:
 - Web crawling capabilities
 - Query-aware content compression
 - Token cost reduction

from server.ai_crawler import AICrawler

crawler = AICrawler(
max_pages=5,
compression_ratio=0.3  Reduce token usage by 70%
)

4. Implementing Case-Based Reasoning with Memory-Augmented Learning

The heart of Memento’s learning capability is its case-based reasoning (CBR) implementation, which stores and retrieves experiences as cases in a structured format.

Case Storage Format:

Each case in the Case Bank stores the final-step tuple (s_T, a_T, r_T) – state, action, and reward. Cases are organized semantically into meaningful clusters, enabling efficient retrieval.

Non-Parametric Retrieval (Nearest Neighbour):

from memento.memory import CaseBank
from memento.retrieval import NearestNeighborRetriever

Initialize case bank and retriever
case_bank = CaseBank(storage_path="./case_bank")
retriever = NearestNeighborRetriever(case_bank)

Retrieve similar cases for a new task
query_embedding = embed_task("New complex query")
similar_cases = retriever.retrieve(query_embedding, k=5)

Each case contains: task, steps, tools used, outcome
for case in similar_cases:
print(f"Task: {case.task}")
print(f"Steps: {case.step_sequence}")
print(f"Outcome: {case.outcome}")

Parametric Retrieval with Neural Q-Learning:

For more sophisticated retrieval, Memento employs a neural case-selection policy trained with soft Q-learning:

from memento.retrieval import NeuralRetriever
from memento.rl import SoftQLearning

Initialize neural retriever
neural_retriever = NeuralRetriever(
embedding_model="text-embedding-3-small",
q_network_hidden_dim=256
)

Train retrieval policy with soft Q-learning
trainer = SoftQLearning(
retriever=neural_retriever,
learning_rate=1e-4,
temperature=1.0  Controls exploration-exploitation balance
)

The retrieval policy naturally takes the form of a softmax over Q-values
 where higher-utility cases are more likely to be selected

5. Benchmark Performance and Real-World Results

Memento has demonstrated exceptional performance across multiple demanding benchmarks, validating its approach to memory-based continual learning.

Key Benchmark Results:

  • GAIA Validation: Top-1 performance with 87.88% Pass@3
  • GAIA Test Set: 79.40% accuracy
  • DeepResearcher: 66.6% F1 score and 80.4% PM, outperforming state-of-the-art training-based methods
  • SimpleQA: 95% accuracy, demonstrating significant hallucination reduction
  • HLE (Humanity’s Last Exam): Sustained gains with 26.2% relative improvement in overall accuracy

Continual Learning Improvements:

Memento’s case-based memory adds 4.7% to 9.6% absolute points on out-of-distribution tasks, showcasing its ability to generalize beyond training data. The system demonstrates progressive improvement across reflective learning rounds, with the skill memory growing and organizing learned skills into semantically meaningful clusters.

  1. Advanced Configuration: MCP Server Integration and Memory Types

Memento’s MCP server provides persistent memory capabilities across multiple platforms. The server implements a sophisticated memory management protocol with multiple memory types inspired by cognitive science:

Memory Types Supported:

  • Core Memory: Foundation operational memory
  • Episodic Memory: Storage of specific experiences and trajectories
  • Semantic Memory: General knowledge and concepts
  • Procedural Memory: Skills and task execution patterns
  • Vault Memory: Secure, encrypted storage for sensitive information

MCP Server Configuration:

{
"mcpServers": {
"memento": {
"command": "python",
"args": ["-m", "memento.mcp_server"],
"env": {
"MEMENTO_STORAGE": "./memento_storage",
"MEMENTO_MEMORY_TYPES": "core,episodic,semantic,procedural,vault"
}
}
}
}

Integration with MCP Clients:

Memento works with any LLM client that supports the Model Context Protocol. The server automatically injects its memory management protocol via the `memento_onboarding()` tool. For detailed agent configurations and copy-paste prompt templates, refer to `AGENT_CONFIGURATION.md` in the repository.

7. Practical Workflow: End-to-End Task Execution

A typical Memento workflow follows the retrieve → reuse & revise → execute → retain → update loop:

from memento.agent import MementoAgent
from memento.planner import MetaPlanner
from memento.executor import MCPExecutor

Initialize agent components
planner = MetaPlanner(model="gpt-4.1")
executor = MCPExecutor(tools=["search", "code_execution", "document_processing"])
agent = MementoAgent(planner=planner, executor=executor)

Process a new task
task = "Research the latest AI safety regulations and generate a compliance report"
result = agent.process(task)

The agent will:
 1. Break down the task into subtasks
 2. Retrieve relevant past cases from Case Bank
 3. Execute each subtask using appropriate MCP tools
 4. Log outcomes back to Case Bank
 5. Update retrieval policy based on rewards

print(f"Final result: {result}")

What Undercode Say:

  • Key Takeaway 1: Memento represents a paradigm shift from gradient-based learning to memory-based learning, fundamentally reducing the cost and complexity of LLM agent adaptation while achieving superior performance on complex, long-horizon tasks.

  • Key Takeaway 2: The framework’s ability to achieve 4.7% to 9.6% absolute gains on out-of-distribution tasks without any parameter updates demonstrates that external memory and case-based reasoning can effectively address the generalization challenges that plague traditional fine-tuning approaches.

  • Analysis: The implications of Memento’s approach extend far beyond academic benchmarks. By decoupling learning from parameter updates, organizations can deploy LLM agents that continuously improve from real-world interactions without the prohibitive costs and risks of frequent fine-tuning. The framework’s MCP-based tool ecosystem enables seamless integration with existing infrastructure, while the memory-augmented decision process provides interpretability – you can see exactly which past cases influenced each decision. This transparency is crucial for enterprise adoption in regulated industries.

  • Analysis: The 90% cost reduction in model adaptation positions Memento as a game-changer for organizations looking to deploy AI at scale. Traditional fine-tuning costs – hundreds of GPU hours and tens of thousands of dollars per iteration – become unnecessary. Instead, agents learn through experience, storing and retrieving cases in a continuously growing knowledge base that improves with every interaction.

Prediction:

+N The proliferation of memory-based learning frameworks like Memento will democratize advanced AI capabilities, enabling smaller organizations to deploy sophisticated LLM agents without the infrastructure required for traditional fine-tuning.

+N As the Memento framework matures, we can expect to see an ecosystem of specialized MCP tools and case libraries emerge, allowing agents to share and reuse learned experiences across different deployments and organizations.

-1 The reliance on external memory systems introduces new security and privacy considerations – organizations must carefully manage what cases are stored and who can access them, as case banks effectively become repositories of organizational knowledge and decision patterns.

+N The integration of Memento with existing LLM workflows will likely accelerate the development of truly autonomous agents capable of open-ended skill acquisition, advancing machine learning towards more human-like learning paradigms.

-1 Organizations may face challenges in maintaining and curating case banks as they grow, requiring new approaches to memory management, case pruning, and retrieval optimization to maintain performance at scale.

▶️ Related Video (78% Match):

🎯Let’s Practice For Free:

🎓 Live Courses & Certifications:

Join Undercode Academy for Verified Certifications

🚀 Request a Custom Project:

Secure, high-velocity infrastructure and disruptive technological engineering. Contact our engineering team for high-tier development and proprietary systems:
[email protected]
💎 Smart Architecture | 🛡️ Secure by Design | ⭐ Trusted by Thousands

IT/Security Reporter URL:

Reported By: Sumanth077 Fine – Hackers Feeds
Extra Hub: Undercode MoN
Basic Verification: Pass ✅

🔐JOIN OUR CYBER WORLD [ CVE News • HackMonitor • UndercodeNews ]

💬 Whatsapp | 💬 Telegram

📢 Follow UndercodeTesting & Stay Tuned:

𝕏 formerly Twitter 🐦 | @ Threads | 🔗 Linkedin | 🦋BlueSky