<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom" xmlns:dc="http://purl.org/dc/elements/1.1/">
  <channel>
    <title>DEV Community: Gayathri</title>
    <description>The latest articles on DEV Community by Gayathri (@gayathri_reddy16).</description>
    <link>https://dev.to/gayathri_reddy16</link>
    <image>
      <url>https://media2.dev.to/dynamic/image/width=90,height=90,fit=cover,gravity=auto,format=auto/https:%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Fuser%2Fprofile_image%2F4145858%2F1dfee10c-fbd8-4987-b9e1-b3c9a81b68b1.jpg</url>
      <title>DEV Community: Gayathri</title>
      <link>https://dev.to/gayathri_reddy16</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://dev.to/feed/gayathri_reddy16"/>
    <language>en</language>
    <item>
      <title>How We Made an LLM Actually Use Recalled Memory</title>
      <dc:creator>Gayathri</dc:creator>
      <pubDate>Sun, 27 Sep 2026 18:13:32 +0000</pubDate>
      <link>https://dev.to/gayathri_reddy16/how-we-made-an-llm-actually-use-recalled-memory-3cl</link>
      <guid>https://dev.to/gayathri_reddy16/how-we-made-an-llm-actually-use-recalled-memory-3cl</guid>
      <description>&lt;p&gt;Making Recalled Memory Actually Influence LLM Recommendations&lt;/p&gt;

&lt;p&gt;When we integrated Hindsight into PayEcho, retrieving a customer's history was not the difficult part.&lt;/p&gt;

&lt;p&gt;The difficult part was getting the language model to actually use that history when generating a recommendation.&lt;/p&gt;

&lt;p&gt;The model could see the recalled information in its context and still produce almost the same generic answer it would give to a customer with no history.&lt;/p&gt;

&lt;p&gt;That became the main engineering problem I worked on:&lt;/p&gt;

&lt;p&gt;How do you make recalled memory act as evidence for an LLM's recommendation instead of just additional context?&lt;/p&gt;

&lt;p&gt;The initial approach&lt;/p&gt;

&lt;p&gt;PayEcho is a payment-recovery and credit-decision agent.&lt;/p&gt;

&lt;p&gt;For payment recovery, the system needs to consider things such as:&lt;/p&gt;

&lt;p&gt;previous recovery attempts&lt;br&gt;
communication channels&lt;br&gt;
customer responses&lt;br&gt;
payment outcomes&lt;br&gt;
timing of previous follow-ups&lt;/p&gt;

&lt;p&gt;The first version of the recommendation flow was straightforward:&lt;/p&gt;

&lt;p&gt;Get the current invoice.&lt;br&gt;
Recall the customer's previous history.&lt;br&gt;
Give both to the language model.&lt;br&gt;
Ask it for a recommendation.&lt;/p&gt;

&lt;p&gt;The model produced a reasonable-looking answer.&lt;/p&gt;

&lt;p&gt;But there was a problem.&lt;/p&gt;

&lt;p&gt;For a customer with several months of recorded behavior, the recommendation could look almost identical to the recommendation for a customer the system had never seen before:&lt;/p&gt;

&lt;p&gt;"Send a polite email reminder, and follow up in 3–5 business days if no response."&lt;/p&gt;

&lt;p&gt;The historical information was present in the context.&lt;/p&gt;

&lt;p&gt;The model simply wasn't required to use it.&lt;/p&gt;

&lt;p&gt;Having memory is not the same as using memory&lt;/p&gt;

&lt;p&gt;This was the distinction that became important in the implementation.&lt;/p&gt;

&lt;p&gt;A system can technically have a memory layer:&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Farticles%2Fisht41l44aetajd49abw.jpeg" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Farticles%2Fisht41l44aetajd49abw.jpeg" alt=" " width="800" height="369"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;But that does not guarantee that the generated response is based on those events.&lt;/p&gt;

&lt;p&gt;The model can treat the recalled information as background context and fall back to a generic recommendation.&lt;/p&gt;

&lt;p&gt;So the problem wasn't initially the memory retrieval itself.&lt;/p&gt;

&lt;p&gt;It was the connection between retrieval and reasoning.&lt;/p&gt;

&lt;p&gt;Making memory part of the reasoning&lt;/p&gt;

&lt;p&gt;The change was surprisingly small.&lt;/p&gt;

&lt;p&gt;Instead of simply asking the model to make a recommendation using the available history, the recommendation needed to cite the specific previous outcome that justified the recommendation.&lt;/p&gt;

&lt;p&gt;For example, suppose the recalled history showed that a customer:&lt;/p&gt;

&lt;p&gt;ignored previous email reminders&lt;br&gt;
responded to WhatsApp&lt;br&gt;
completed payment after a follow-up three days later&lt;/p&gt;

&lt;p&gt;The recommendation could then be:&lt;/p&gt;

&lt;p&gt;"ABC previously ignored email reminders but responded to WhatsApp, and completed payment after a 3-day follow-up. Recommend WhatsApp outreach with a scheduled 3-day follow-up."&lt;/p&gt;

&lt;p&gt;That is different from simply saying:&lt;/p&gt;

&lt;p&gt;"The customer has previous payment history."&lt;/p&gt;

&lt;p&gt;The first recommendation identifies the evidence that influenced the decision.&lt;/p&gt;

&lt;p&gt;This made the memory load-bearing rather than decorative.&lt;/p&gt;

&lt;p&gt;The agent loop&lt;/p&gt;

&lt;p&gt;The recommendation flow in PayEcho is intentionally narrow.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Farticles%2F19aqhxdkiiamiigpp0r7.jpeg" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Farticles%2F19aqhxdkiiamiigpp0r7.jpeg" alt=" " width="800" height="450"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;The important part is that the model itself does not change between these interactions.&lt;/p&gt;

&lt;p&gt;What changes is the evidence available to it.&lt;/p&gt;

&lt;p&gt;recall() retrieves previous recovery attempts and outcomes.&lt;/p&gt;

&lt;p&gt;The current invoice is considered alongside that history.&lt;/p&gt;

&lt;p&gt;The model then produces a recommendation involving things such as:&lt;/p&gt;

&lt;p&gt;communication channel&lt;br&gt;
timing&lt;br&gt;
tone&lt;br&gt;
the specific historical event supporting the recommendation&lt;/p&gt;

&lt;p&gt;After the business acts, the actual outcome is written back through retain().&lt;/p&gt;

&lt;p&gt;That outcome can then become evidence for a future recommendation.&lt;/p&gt;

&lt;p&gt;Retrieval and generation are separate&lt;/p&gt;

&lt;p&gt;One architectural decision that helped during development was keeping retrieval and generation as separate stages.&lt;/p&gt;

&lt;p&gt;It would have been possible to combine everything into one step, but separating them made debugging much easier.&lt;/p&gt;

&lt;p&gt;When a recommendation looked generic, there were two different questions:&lt;/p&gt;

&lt;p&gt;Did recall() return useful history?&lt;/p&gt;

&lt;p&gt;or&lt;/p&gt;

&lt;p&gt;Did the model receive useful history but fail to reason from it?&lt;/p&gt;

&lt;p&gt;With separate stages, those questions could be investigated independently.&lt;/p&gt;

&lt;p&gt;This matters because "the agent gave a bad recommendation" doesn't necessarily mean the same thing as "the memory system failed."&lt;/p&gt;

&lt;p&gt;The failure could be in retrieval.&lt;/p&gt;

&lt;p&gt;It could be in how the retrieved information was presented.&lt;/p&gt;

&lt;p&gt;Or it could be in the model's reasoning.&lt;/p&gt;

&lt;p&gt;Separating the stages made that distinction visible.&lt;/p&gt;

&lt;p&gt;The credit-decision case is different&lt;/p&gt;

&lt;p&gt;PayEcho also has a credit-decision use case, but I intentionally kept the model's responsibility narrower there.&lt;/p&gt;

&lt;p&gt;For payment recovery, the agent can recommend an action.&lt;/p&gt;

&lt;p&gt;For a credit decision, the agent surfaces relevant evidence instead of automatically approving or denying the request.&lt;/p&gt;

&lt;p&gt;For example, if a customer has a history of late payments and requests additional credit, the system can summarize the repayment history for the person making the decision.&lt;/p&gt;

&lt;p&gt;The final financial decision remains with the human.&lt;/p&gt;

&lt;p&gt;The distinction is important:&lt;/p&gt;

&lt;p&gt;Recovery:&lt;br&gt;
History → Reasoning → Recommended action&lt;/p&gt;

&lt;p&gt;Credit decision:&lt;br&gt;
History → Reasoning → Evidence for human decision&lt;/p&gt;

&lt;p&gt;The same memory and reasoning approach can support both cases, but the authority given to the model is different.&lt;/p&gt;

&lt;p&gt;Handling empty memory&lt;/p&gt;

&lt;p&gt;A memory-based agent also needs to handle the situation where there simply isn't any useful history.&lt;/p&gt;

&lt;p&gt;For a new customer, recall() can return no relevant events.&lt;/p&gt;

&lt;p&gt;In that situation, the system shouldn't manufacture personalization.&lt;/p&gt;

&lt;p&gt;Instead, it explicitly treats the customer as having no relevant history and uses a sensible generic recommendation.&lt;/p&gt;

&lt;p&gt;That gives the system two clearly different states:&lt;/p&gt;

&lt;p&gt;No relevant history&lt;br&gt;
        ↓&lt;br&gt;
Generic starting recommendation&lt;/p&gt;

&lt;p&gt;and:&lt;/p&gt;

&lt;p&gt;Relevant history&lt;br&gt;
        ↓&lt;br&gt;
Recommendation grounded in previous outcomes&lt;/p&gt;

&lt;p&gt;The absence of memory is therefore an explicit state rather than something the model is expected to hide.&lt;/p&gt;

&lt;p&gt;Failure handling matters too&lt;/p&gt;

&lt;p&gt;LLM-based systems don't always return perfect output.&lt;/p&gt;

&lt;p&gt;Function-calling errors, malformed responses, and rate limits are possible.&lt;/p&gt;

&lt;p&gt;The agent layer therefore includes retry handling with backoff and a fallback recommendation rather than exposing a raw generation failure to the person using the dashboard.&lt;/p&gt;

&lt;p&gt;The goal isn't to pretend that the model never fails.&lt;/p&gt;

&lt;p&gt;The goal is to make failure predictable and recoverable.&lt;/p&gt;

&lt;p&gt;What changed as history accumulated?&lt;/p&gt;

&lt;p&gt;The behavior also changed as more interactions were retained for the same customer.&lt;/p&gt;

&lt;p&gt;With zero prior events, the system uses its generic fallback. There isn't enough evidence to make a customer-specific recommendation.&lt;/p&gt;

&lt;p&gt;With one or two retained events, recommendations can begin referencing a specific channel that previously worked.&lt;/p&gt;

&lt;p&gt;By the third or fourth retained interaction, the recommendation can incorporate more of the observed behavior, including timing, tone, and channel.&lt;/p&gt;

&lt;p&gt;For example, instead of simply recommending a reminder, the recommendation can be grounded in the customer's previously observed response pattern.&lt;/p&gt;

&lt;p&gt;The important point is not that more memory automatically makes the model better.&lt;/p&gt;

&lt;p&gt;It is that relevant retained outcomes give the model more evidence to reason from.&lt;/p&gt;

&lt;p&gt;What I learned&lt;/p&gt;

&lt;p&gt;There were three lessons that stood out from building this layer.&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;Don't assume the model will use memory just because it can see it&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;Putting recalled information into the context window isn't enough.&lt;/p&gt;

&lt;p&gt;If memory is supposed to influence the recommendation, the generation step needs to make that relationship explicit.&lt;/p&gt;

&lt;p&gt;Requiring the recommendation to identify the relevant past outcome was a simple way to do that.&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;Keep recommendation and decision-making separate&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;An agent can summarize evidence or recommend an action without necessarily owning the final decision.&lt;/p&gt;

&lt;p&gt;This distinction was especially important for the credit-decision part of PayEcho.&lt;/p&gt;

&lt;p&gt;The system can surface repayment history without automatically making a financial decision.&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;Design the failure path early&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;Empty memory, malformed output, function-calling failures, and rate limits are part of building an LLM application.&lt;/p&gt;

&lt;p&gt;A retry strategy and an honest fallback are easier to reason about when they are designed as part of the agent architecture rather than added after something breaks.&lt;/p&gt;

&lt;p&gt;Why this pattern is broader than payment recovery&lt;/p&gt;

&lt;p&gt;The same problem appears anywhere an agent needs to reason over historical interactions.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Farticles%2Fhyash72durear8rgpd06.jpeg" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Farticles%2Fhyash72durear8rgpd06.jpeg" alt=" " width="800" height="533"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;support systems can recall previous customer issues&lt;br&gt;
sales assistants can recall previous follow-ups&lt;br&gt;
incident-response agents can recall earlier incidents&lt;br&gt;
operations systems can recall previous actions and outcomes&lt;/p&gt;

&lt;p&gt;In all of these cases, there is a difference between:&lt;/p&gt;

&lt;p&gt;The system has memory.&lt;/p&gt;

&lt;p&gt;and:&lt;/p&gt;

&lt;p&gt;The system's current reasoning is grounded in that memory.&lt;/p&gt;

&lt;p&gt;That distinction is what mattered most in PayEcho.&lt;/p&gt;

&lt;p&gt;Final takeaway&lt;/p&gt;

&lt;p&gt;The interesting part of adding memory to an AI agent isn't just storing and retrieving previous events.&lt;/p&gt;

&lt;p&gt;The harder problem is making those events useful evidence for the next decision.&lt;/p&gt;

&lt;p&gt;For PayEcho, the resulting loop is:&lt;/p&gt;

&lt;p&gt;Retain the outcome&lt;br&gt;
       ↓&lt;br&gt;
Recall relevant history&lt;br&gt;
       ↓&lt;br&gt;
Reason using that history&lt;br&gt;
       ↓&lt;br&gt;
Make a recommendation&lt;br&gt;
       ↓&lt;br&gt;
Observe the outcome&lt;br&gt;
       ↓&lt;br&gt;
Retain again&lt;/p&gt;

</description>
      <category>ai</category>
      <category>programming</category>
      <category>javascript</category>
      <category>python</category>
    </item>
  </channel>
</rss>
