<?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: Arpitha M V</title>
    <description>The latest articles on DEV Community by Arpitha M V (@arpitha_mv).</description>
    <link>https://dev.to/arpitha_mv</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%2F4232607%2F880f12b1-5bd1-4072-9cf5-d8fc3bb336c1.png</url>
      <title>DEV Community: Arpitha M V</title>
      <link>https://dev.to/arpitha_mv</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://dev.to/feed/arpitha_mv"/>
    <language>en</language>
    <item>
      <title>What I Learned Replacing Flat RAG with Dual-Bank Memory</title>
      <dc:creator>Arpitha M V</dc:creator>
      <pubDate>Sat, 07 Nov 2026 18:13:11 +0000</pubDate>
      <link>https://dev.to/arpitha_mv/what-i-learned-replacing-flat-rag-with-dual-bank-memory-4525</link>
      <guid>https://dev.to/arpitha_mv/what-i-learned-replacing-flat-rag-with-dual-bank-memory-4525</guid>
      <description>&lt;p&gt;&lt;a href="https://vectorize.io/what-is-agent-memory" rel="noopener noreferrer"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h1&gt;
  
  
  Why I Replaced Flat Support RAG with Dual-Bank Agent Memory Using Hindsight
&lt;/h1&gt;

&lt;p&gt;Enterprise customer support systems fail for two predictable reasons: session amnesia and isolated silos. When a customer opens a ticket, standard stateless LLM wrappers have no memory of the user's operating system, subscription tier, or the troubleshooting steps they already ran forty-eight hours ago. Worse, when companies bolt on a naive per-user vector database, they create a secondary failure mode: if Customer A spends an hour helping engineering discover a workaround for a critical PDF export bug, the support agent talking to Customer B five minutes later has zero visibility into that resolution.&lt;/p&gt;

&lt;p&gt;While building our stateful support engine (&lt;code&gt;hindsight-customer-support-agent&lt;/code&gt;), I wanted to eliminate both failure modes without stuffing raw chat transcripts into a 128k context window. By pairing &lt;a href="https://vectorize.io/what-is-agent-memory" rel="noopener noreferrer"&gt;Vectorize agent memory&lt;/a&gt; with DeepSeek via OpenRouter, we designed a &lt;strong&gt;Dual-Bank Hierarchical Memory Architecture&lt;/strong&gt; that separates private customer state from collective product learnings.&lt;/p&gt;

&lt;h2&gt;
  
  
  How the Dual-Bank System Hangs Together
&lt;/h2&gt;

&lt;p&gt;Instead of treating memory as a single flat index, our core orchestrator in &lt;code&gt;agent.py&lt;/code&gt; routes every incoming ticket through two distinct namespaces hosted on Hindsight Cloud (&lt;code&gt;api.hindsight.vectorize.io&lt;/code&gt;) via the official &lt;code&gt;hindsight-client&lt;/code&gt; SDK (v1.2.0):&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;
&lt;strong&gt;The Personal Episodic Bank (&lt;code&gt;cust_001&lt;/code&gt;, &lt;code&gt;cust_002&lt;/code&gt;, &lt;code&gt;cust_003&lt;/code&gt;):&lt;/strong&gt; Stores tenant-isolated facts—operating system, subscription tier, billing history, and explicit communication preferences (for example, whether the customer wants raw Linux CLI commands or beginner-friendly GUI steps).&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;The Shared Hive-Mind Bank (&lt;code&gt;global_product_learnings&lt;/code&gt;):&lt;/strong&gt; Stores PII-stripped technical bug resolutions and product workarounds discovered across all support conversations.&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;When a ticket arrives, the system executes a deterministic &lt;strong&gt;Recall -&amp;gt; Reason -&amp;gt; Retain&lt;/strong&gt; cognitive loop. You can explore the underlying memory primitives in the &lt;a href="https://github.com/vectorize-io/hindsight" rel="noopener noreferrer"&gt;Hindsight GitHub&lt;/a&gt; repository.&lt;/p&gt;

&lt;h2&gt;
  
  
  Code Walkthrough: Dual-Bank Recall and Selective Retention
&lt;/h2&gt;

&lt;p&gt;In &lt;code&gt;agent.py&lt;/code&gt;, our &lt;code&gt;generate_support_reply&lt;/code&gt; function queries both the customer's personal memory bank and the global learnings bank before constructing the system prompt for DeepSeek (&lt;code&gt;deepseek/deepseek-v3.2&lt;/code&gt;):&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight python"&gt;&lt;code&gt;&lt;span class="kn"&gt;import&lt;/span&gt; &lt;span class="n"&gt;time&lt;/span&gt;
&lt;span class="kn"&gt;from&lt;/span&gt; &lt;span class="n"&gt;datetime&lt;/span&gt; &lt;span class="kn"&gt;import&lt;/span&gt; &lt;span class="n"&gt;datetime&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;timezone&lt;/span&gt;
&lt;span class="kn"&gt;from&lt;/span&gt; &lt;span class="n"&gt;hindsight_client&lt;/span&gt; &lt;span class="kn"&gt;import&lt;/span&gt; &lt;span class="n"&gt;Hindsight&lt;/span&gt;

&lt;span class="n"&gt;hindsight&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nc"&gt;Hindsight&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;
    &lt;span class="n"&gt;api_key&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="n"&gt;HINDSIGHT_API_KEY&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
    &lt;span class="n"&gt;base_url&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt;[https://api.hindsight.vectorize.io](https://api.hindsight.vectorize.io)&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;
&lt;span class="p"&gt;)&lt;/span&gt;

&lt;span class="k"&gt;def&lt;/span&gt; &lt;span class="nf"&gt;recall_dual_bank_context&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;customer_id&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="nb"&gt;str&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;query&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="nb"&gt;str&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="o"&gt;-&amp;gt;&lt;/span&gt; &lt;span class="nb"&gt;tuple&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="nb"&gt;str&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nb"&gt;str&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nb"&gt;int&lt;/span&gt;&lt;span class="p"&gt;]:&lt;/span&gt;
    &lt;span class="n"&gt;t0&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;time&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;perf_counter&lt;/span&gt;&lt;span class="p"&gt;()&lt;/span&gt;

    &lt;span class="c1"&gt;# 1. Recall private customer context (OS, tier, tone rules, past tickets)
&lt;/span&gt;    &lt;span class="n"&gt;personal_resp&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;hindsight&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;recall&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;bank_id&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="n"&gt;customer_id&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;query&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="n"&gt;query&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
    &lt;span class="n"&gt;personal_context&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;_&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nf"&gt;parse_hindsight_recall&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;personal_resp&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;

    &lt;span class="c1"&gt;# 2. Recall cross-customer technical bug workarounds
&lt;/span&gt;    &lt;span class="n"&gt;global_resp&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;hindsight&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;recall&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;bank_id&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt;global_product_learnings&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;query&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="n"&gt;query&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
    &lt;span class="n"&gt;global_context&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;_&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nf"&gt;parse_hindsight_recall&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;global_resp&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;

    &lt;span class="n"&gt;recall_ms&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nf"&gt;int&lt;/span&gt;&lt;span class="p"&gt;((&lt;/span&gt;&lt;span class="n"&gt;time&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;perf_counter&lt;/span&gt;&lt;span class="p"&gt;()&lt;/span&gt; &lt;span class="o"&gt;-&lt;/span&gt; &lt;span class="n"&gt;t0&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="o"&gt;*&lt;/span&gt; &lt;span class="mi"&gt;1000&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
    &lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="n"&gt;personal_context&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;global_context&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;recall_ms&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Once both memory blocks are retrieved, we inject them into distinct sections of the system prompt. This prevents cross-tenant data leakage while giving the reasoning model immediate access to verified product fixes:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight python"&gt;&lt;code&gt;&lt;span class="n"&gt;system_prompt&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="sa"&gt;f&lt;/span&gt;&lt;span class="sh"&gt;"""&lt;/span&gt;&lt;span class="s"&gt;You are a Senior Technical Support Engineer.
Apply the verified longitudinal memory below without asking the customer to repeat known facts.

=== PERSONAL CUSTOMER MEMORY (Bank: &lt;/span&gt;&lt;span class="si"&gt;{&lt;/span&gt;&lt;span class="n"&gt;customer_id&lt;/span&gt;&lt;span class="si"&gt;}&lt;/span&gt;&lt;span class="s"&gt;) ===
&lt;/span&gt;&lt;span class="si"&gt;{&lt;/span&gt;&lt;span class="n"&gt;personal_context&lt;/span&gt;&lt;span class="si"&gt;}&lt;/span&gt;&lt;span class="s"&gt;

=== SHARED PRODUCT BUG LEARNINGS (Bank: global_product_learnings) ===
&lt;/span&gt;&lt;span class="si"&gt;{&lt;/span&gt;&lt;span class="n"&gt;global_context&lt;/span&gt;&lt;span class="si"&gt;}&lt;/span&gt;&lt;span class="s"&gt;

OPERATING RULES:
1. Match the customer&lt;/span&gt;&lt;span class="sh"&gt;'&lt;/span&gt;&lt;span class="s"&gt;s exact OS, plan tier, and communication style.
2. Skip Tier-1 checklists if prior tickets show those steps were already attempted.
3. Apply verified workarounds from global_product_learnings when relevant.&lt;/span&gt;&lt;span class="sh"&gt;"""&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;After the LLM generates a resolution, we don't blindly dump noisy greetings back into storage. We commit the interaction to the customer's personal bank with temporal metadata, and if a reusable technical workaround was identified, we commit a sanitized summary to &lt;code&gt;global_product_learnings&lt;/code&gt;:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight python"&gt;&lt;code&gt;&lt;span class="n"&gt;interaction_record&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="sa"&gt;f&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt;Customer (&lt;/span&gt;&lt;span class="si"&gt;{&lt;/span&gt;&lt;span class="n"&gt;customer_id&lt;/span&gt;&lt;span class="si"&gt;}&lt;/span&gt;&lt;span class="s"&gt;) asked: &lt;/span&gt;&lt;span class="si"&gt;{&lt;/span&gt;&lt;span class="n"&gt;user_message&lt;/span&gt;&lt;span class="si"&gt;}&lt;/span&gt;&lt;span class="s"&gt; | Agent resolved: &lt;/span&gt;&lt;span class="si"&gt;{&lt;/span&gt;&lt;span class="n"&gt;agent_reply&lt;/span&gt;&lt;span class="si"&gt;}&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;
&lt;span class="n"&gt;hindsight&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;retain&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;
    &lt;span class="n"&gt;bank_id&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="n"&gt;customer_id&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
    &lt;span class="n"&gt;content&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="n"&gt;interaction_record&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
    &lt;span class="n"&gt;context&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt;support_interaction&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
    &lt;span class="n"&gt;timestamp&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="n"&gt;datetime&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;now&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;timezone&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;utc&lt;/span&gt;&lt;span class="p"&gt;).&lt;/span&gt;&lt;span class="nf"&gt;isoformat&lt;/span&gt;&lt;span class="p"&gt;()&lt;/span&gt;
&lt;span class="p"&gt;)&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Full details on configuring bank namespaces and retention parameters are available in the &lt;a href="https://hindsight.vectorize.io/" rel="noopener noreferrer"&gt;Hindsight documentation&lt;/a&gt;.&lt;/p&gt;

&lt;h2&gt;
  
  
  Concrete Behavior: Before vs. After Dual-Bank Memory
&lt;/h2&gt;

&lt;p&gt;To see the architecture in action, consider two seeded customer profiles in our system:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;Alex (&lt;code&gt;cust_001&lt;/code&gt;):&lt;/strong&gt; Senior Developer on Ubuntu Linux (Enterprise Tier). Hates generic troubleshooting checklists; wants direct bash commands. Previously resolved a PDF export crash caused by ad-blockers intercepting blob URLs.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;David (&lt;code&gt;cust_003&lt;/code&gt;):&lt;/strong&gt; Small business owner on macOS (Starter Plan). Overwhelmed by technical jargon; needs numbered, plain-English UI instructions.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;strong&gt;With Hindsight Memory Disabled (Stateless Mode):&lt;/strong&gt;&lt;br&gt;
When Alex messages &lt;em&gt;"The export issue is happening again. How do I fix it?"&lt;/em&gt;, the stateless model responds with a generic six-step checklist asking what operating system and browser he uses.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;With Hindsight Dual-Bank Memory Enabled:&lt;/strong&gt;&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;Querying &lt;code&gt;cust_001&lt;/code&gt; recalls that Alex runs Ubuntu, is on the Enterprise tier, and previously hit the ad-blocker PDF export bug. The agent immediately replies with the CLI flag and Brave/uBlock blob whitelist command—zero clarifying questions asked.&lt;/li&gt;
&lt;li&gt;When Alex replies with a newly discovered fix (&lt;em&gt;"Disabling hardware acceleration in v2.5 fixed the canvas renderer crash"&lt;/em&gt;), the agent retains that sanitized technical fact into &lt;code&gt;global_product_learnings&lt;/code&gt;.&lt;/li&gt;
&lt;li&gt;Two minutes later, when David (&lt;code&gt;cust_003&lt;/code&gt;) reports that his canvas is crashing, the agent recalls David's non-technical macOS persona from &lt;code&gt;cust_003&lt;/code&gt; alongside Alex's hardware acceleration fix from &lt;code&gt;global_product_learnings&lt;/code&gt;—translating a developer's workaround into three gentle, click-by-click macOS steps for David.&lt;/li&gt;
&lt;/ol&gt;

&lt;h2&gt;
  
  
  Engineering Takeaways
&lt;/h2&gt;

&lt;ol&gt;
&lt;li&gt;
&lt;strong&gt;Separate Episodic Identity from Semantic Product Knowledge:&lt;/strong&gt; Isolating &lt;code&gt;cust_00X&lt;/code&gt; from &lt;code&gt;global_product_learnings&lt;/code&gt; gives you strict multi-tenant privacy while allowing every customer ticket to make the entire support system smarter.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Latency Budgets Matter:&lt;/strong&gt; Decoupling memory retrieval via &lt;code&gt;hindsight-client&lt;/code&gt; keeps prompt tokens compact and predictable compared to stuffing raw ticket histories into the context window.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;AI-Assisted Iteration:&lt;/strong&gt; Using terminal-first agentic workflows and tools like Code.in alongside tight validation scripts (&lt;code&gt;test_agent.py&lt;/code&gt;) allowed us to refactor our single-bank prototype into a dual-bank architecture without breaking existing recall assertions.&lt;/li&gt;
&lt;/ol&gt;

</description>
      <category>agents</category>
      <category>llm</category>
      <category>rag</category>
      <category>vectordatabase</category>
    </item>
  </channel>
</rss>
