I recently encountered a frustrating issue with a support bot I'd built using LangGraph. The bot was designed to help users troubleshoot common problems with their smart home devices. However, I noticed that it would often forget the context of the conversation, asking the user to repeat information they'd already provided. This wasn't just annoying - it was also a major obstacle to providing effective support. The bot's inability to retain context-dependent knowledge across multiple interactions made it seem like it was starting from scratch every time the user asked a follow-up question.

After digging into the code, I realized that the problem lay in the way I was handling the bot's episodic memory. Episodic memory refers to the ability of an agent to recall specific events or experiences from the past. In the case of my support bot, this meant remembering the details of the user's previous interactions, such as the device they were trying to troubleshoot and the steps they'd already taken. I was using a simple in-memory store to keep track of this information, which was being lost whenever the conversation ended or the bot was restarted.

To fix this issue, I decided to use the Resource primitive from the Model Context Protocol (MCP) to persist and retrieve the bot's episodic memory. The Resource primitive allows you to define a shared context that can be accessed and updated by multiple components within an agent. This made it ideal for storing the bot's episodic memory, as it would allow me to persist the memory across multiple conversations and user interactions.