<?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: M Pranay</title>
    <description>The latest articles on DEV Community by M Pranay (@m_pranay_1216).</description>
    <link>https://dev.to/m_pranay_1216</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%2F4148403%2F3252c0ca-a836-4989-94c3-8d3d63c2c332.png</url>
      <title>DEV Community: M Pranay</title>
      <link>https://dev.to/m_pranay_1216</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://dev.to/feed/m_pranay_1216"/>
    <language>en</language>
    <item>
      <title># Hindsight Remembered the Cases; My Code Chose the Evidence</title>
      <dc:creator>M Pranay</dc:creator>
      <pubDate>Tue, 29 Sep 2026 03:16:05 +0000</pubDate>
      <link>https://dev.to/m_pranay_1216/-hindsight-remembered-the-cases-my-code-chose-the-evidence-1eli</link>
      <guid>https://dev.to/m_pranay_1216/-hindsight-remembered-the-cases-my-code-chose-the-evidence-1eli</guid>
      <description>&lt;h1&gt;
  
  
  Hindsight Remembered the Cases; Code Chose the Evidence
&lt;/h1&gt;

&lt;p&gt;The hardest part of giving an agent memory was not storing more information. It was deciding what that memory was actually allowed to prove.&lt;/p&gt;

&lt;p&gt;I built &lt;strong&gt;Echo&lt;/strong&gt;, an accounts-payable exception investigation system that combines persistent institutional memory with deterministic evidence processing. When an invoice hits an exception, Echo compares the written policy with what happened in similar historical cases, shows the conditions behind those decisions, and gives a human the evidence needed to make the final decision.&lt;/p&gt;

&lt;p&gt;The project is open on GitHub:&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;&lt;a href="https://github.com/MudadlaPranay12/echo" rel="noopener noreferrer"&gt;Echo — AP Exception Intelligence Agent&lt;/a&gt;&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;The important architectural decision is simple:&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;&lt;strong&gt;Hindsight stores memory. Deterministic code decides what counts as evidence. The LLM explains that evidence.&lt;/strong&gt;&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;That separation changed the way I designed the entire system.&lt;/p&gt;




&lt;h2&gt;
  
  
  The problem: policy is not always practice
&lt;/h2&gt;

&lt;p&gt;Accounts payable looks straightforward until an invoice does not fit the normal process.&lt;/p&gt;

&lt;p&gt;An invoice may have:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;an amount mismatch&lt;/li&gt;
&lt;li&gt;a missing purchase order&lt;/li&gt;
&lt;li&gt;a GST mismatch&lt;/li&gt;
&lt;li&gt;a suspected duplicate&lt;/li&gt;
&lt;li&gt;a policy threshold violation&lt;/li&gt;
&lt;li&gt;a special condition that changes how the exception is handled&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;The written policy can tell an AP operator what should happen.&lt;/p&gt;

&lt;p&gt;But organizations accumulate another layer of knowledge over time:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;which exceptions were actually approved&lt;/li&gt;
&lt;li&gt;which approver handled them&lt;/li&gt;
&lt;li&gt;which workaround was used&lt;/li&gt;
&lt;li&gt;under which condition the approval happened&lt;/li&gt;
&lt;li&gt;whether a particular exception pattern repeatedly appeared&lt;/li&gt;
&lt;li&gt;whether historical practice differed from the written route&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;That knowledge is usually scattered across old cases, spreadsheets, emails, and human memory.&lt;/p&gt;

&lt;p&gt;I wanted Echo to make that institutional memory queryable.&lt;/p&gt;

&lt;p&gt;But there was an immediate problem.&lt;/p&gt;

&lt;p&gt;If an agent retrieves five “similar” historical cases, are all five really evidence?&lt;/p&gt;

&lt;p&gt;Not necessarily.&lt;/p&gt;

&lt;p&gt;A case can be semantically similar while belonging to a different policy regime, amount band, condition, or exception pattern.&lt;/p&gt;

&lt;p&gt;So Echo does not allow retrieval alone to determine the conclusion.&lt;/p&gt;




&lt;h2&gt;
  
  
  What Echo does
&lt;/h2&gt;

&lt;p&gt;At a high level, Echo sits between the written AP policy and the human decision-maker.&lt;/p&gt;

&lt;p&gt;The workflow is:&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%2Ftt6ru1y0pdev3aob7u3t.png" 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%2Ftt6ru1y0pdev3aob7u3t.png" alt=" " width="799" height="306"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;The architecture intentionally gives each component a narrow responsibility.&lt;/p&gt;




&lt;h2&gt;
  
  
  The Hindsight integration
&lt;/h2&gt;

&lt;p&gt;The application keeps Hindsight behind a backend memory layer rather than spreading memory calls throughout the UI.&lt;/p&gt;

&lt;p&gt;For example, the case expansion path verifies that Hindsight is configured before writing historical cases:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight typescript"&gt;&lt;code&gt;&lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="nx"&gt;cfg&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nf"&gt;hindsightConfig&lt;/span&gt;&lt;span class="p"&gt;();&lt;/span&gt;

&lt;span class="k"&gt;if &lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="o"&gt;!&lt;/span&gt;&lt;span class="nx"&gt;cfg&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="nx"&gt;console&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;error&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;
    &lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;Hindsight is not configured. Set HINDSIGHT_BANK_ID and HINDSIGHT_BASE_URL in .env.local&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;
  &lt;span class="p"&gt;);&lt;/span&gt;
  &lt;span class="nx"&gt;process&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;exitCode&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="mi"&gt;1&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
  &lt;span class="k"&gt;return&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;

&lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="nx"&gt;cases&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nx"&gt;JSON&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;parse&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;
  &lt;span class="nf"&gt;readFileSync&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;EXPANSION_PATH&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;utf8&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="k"&gt;as&lt;/span&gt; &lt;span class="nx"&gt;ExpansionCase&lt;/span&gt;&lt;span class="p"&gt;[];&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;The important design choice is that the frontend never becomes the memory system itself.&lt;/p&gt;

&lt;p&gt;The runtime retrieval path follows the same separation:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;User / Invoice
      ↓
Identify exception family
      ↓
Recall relevant Hindsight pattern
      ↓
Read supporting case IDs
      ↓
Fetch exact historical cases
      ↓
Apply deterministic comparability
      ↓
Compute evidence + confidence
      ↓
LLM explains the evidence
      ↓
Human decision
      ↓
Retain new resolution
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;This gives the system a clear boundary between memory, evidence, explanation, and decision-making.&lt;/p&gt;




&lt;h2&gt;
  
  
  Two kinds of memory
&lt;/h2&gt;

&lt;p&gt;Echo separates &lt;strong&gt;case memory&lt;/strong&gt; from &lt;strong&gt;pattern memory&lt;/strong&gt;.&lt;/p&gt;

&lt;p&gt;A case represents a concrete historical event:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;case_id: C12
invoice: INV-NW-1193
issue_family: amount_mismatch
approver: Priya Nair
condition: vendor annexure attached
outcome: approved
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;A pattern is an aggregate observation supported by multiple cases:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;pattern:
fuel-surcharge exception

support_count:
5

approved_count:
5

rejected_count:
0

condition:
fuel-surcharge annexure attached

supporting_case_ids:
C02, C04, C08, C10, C12
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;The distinction matters because the pattern can point back to the exact historical cases that support it.&lt;/p&gt;

&lt;p&gt;Hindsight provides persistent memory.&lt;/p&gt;

&lt;p&gt;Echo's deterministic layer decides how that memory becomes evidence.&lt;/p&gt;




&lt;h2&gt;
  
  
  The retrieval boundary
&lt;/h2&gt;

&lt;p&gt;A simple memory implementation could look like this:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;Query
  ↓
Retrieve similar cases
  ↓
Give everything to the LLM
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;I did not want Echo to work that way.&lt;/p&gt;

&lt;p&gt;Instead, the runtime path is:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;Query
  ↓
Identify exception family
  ↓
Recall relevant Hindsight pattern
  ↓
Extract supporting case IDs
  ↓
Read those exact cases
  ↓
Apply comparability rules
  ↓
Exclude the current invoice
  ↓
Compute evidence
  ↓
LLM explains the result
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;The distinction matters.&lt;/p&gt;

&lt;p&gt;Hindsight can find memories that are relevant to the query. That does not automatically mean every retrieved memory is valid evidence for the current invoice.&lt;/p&gt;

&lt;p&gt;Echo therefore evaluates historical cases against deterministic rules.&lt;/p&gt;

&lt;p&gt;The comparison considers the issue family, relevant pattern, applicable policy regime, amount or difference information when available, the side of a policy threshold, and whether the case contains enough information to be compared.&lt;/p&gt;

&lt;p&gt;A historical case that cannot be compared reliably is not silently treated as evidence.&lt;/p&gt;

&lt;p&gt;That became one of the central rules of the project:&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;&lt;strong&gt;Similarity finds candidates. Deterministic logic decides evidence.&lt;/strong&gt;&lt;/p&gt;
&lt;/blockquote&gt;




&lt;h2&gt;
  
  
  Confidence is computed, not generated
&lt;/h2&gt;

&lt;p&gt;I also wanted to keep confidence outside the language model.&lt;/p&gt;

&lt;p&gt;Echo calculates the confidence level from the actual evidence.&lt;/p&gt;

&lt;p&gt;For example:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;5 comparable historical cases

5 / 5 approved

MEDIUM — SMALL SAMPLE
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;The language model can explain what that evidence means, but it does not invent the approval count or confidence level.&lt;/p&gt;

&lt;p&gt;That creates a clear provenance boundary:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;COMPUTED
↓
Deterministic application logic

EVIDENCE
↓
Historical Hindsight cases

SYNTHESIZED
↓
LLM explanation
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;This is important because an explanation can sound convincing even when the underlying evidence is weak.&lt;/p&gt;

&lt;p&gt;Echo therefore keeps the evidence and the explanation visibly separate.&lt;/p&gt;




&lt;h2&gt;
  
  
  A concrete investigation
&lt;/h2&gt;

&lt;p&gt;Consider:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;INV-NW-1188
Northwind Freight
Amount mismatch
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;With memory enabled, Echo retrieves five comparable historical cases:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;C02
C04
C08
C10
C12
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;All five were approved.&lt;/p&gt;

&lt;p&gt;The recurring condition is:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;fuel-surcharge annexure attached
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Instead of simply telling the user that five invoices were “similar,” Echo exposes the evidence chain:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;Exception
   ↓
Fuel-surcharge pattern
   ↓
Annexure attached
   ↓
5 comparable historical cases
   ↓
5 approvals
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;At the same time, Echo shows the written policy separately.&lt;/p&gt;

&lt;p&gt;The user can therefore see:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;WHAT THE POLICY SAYS

vs.

WHAT HISTORICAL PRACTICE SHOWS
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;The point is not to silently replace written policy with history.&lt;/p&gt;

&lt;p&gt;The point is to expose the gap between the written route and historical practice so a human can make the final decision with better context.&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%2F7iia2ntgs4822m1j8thb.png" 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%2F7iia2ntgs4822m1j8thb.png" alt=" " width="800" height="471"&gt;&lt;/a&gt;&lt;/p&gt;




&lt;h2&gt;
  
  
  Before and after persistent memory
&lt;/h2&gt;

&lt;p&gt;The same invoice provides a useful comparison.&lt;/p&gt;

&lt;h3&gt;
  
  
  Before: written policy only
&lt;/h3&gt;

&lt;p&gt;Without historical memory, Echo can still evaluate the invoice against the written rule.&lt;/p&gt;

&lt;p&gt;The system can identify the exception and show the applicable policy route.&lt;/p&gt;

&lt;p&gt;But it has no institutional precedent to show.&lt;/p&gt;

&lt;p&gt;The result is effectively:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;Written policy:
CFO approval required for mismatch
above INR 50,000.

Historical precedent:
None available in memory mode.
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h3&gt;
  
  
  After: persistent institutional memory
&lt;/h3&gt;

&lt;p&gt;With Hindsight enabled, the same investigation can include:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;5 comparable historical cases

C02
C04
C08
C10
C12

5 / 5 approved

Condition:
fuel-surcharge annexure attached
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;That changes the investigation from a pure policy lookup into a policy-plus-practice analysis.&lt;/p&gt;

&lt;p&gt;The user can see both sources of information rather than receiving a single opaque AI conclusion.&lt;/p&gt;




&lt;h2&gt;
  
  
  Memory ON vs Memory OFF
&lt;/h2&gt;

&lt;p&gt;Echo also makes the memory boundary explicit.&lt;/p&gt;

&lt;p&gt;With memory enabled:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;MEMORY ACTIVE

Historical cases:
5

Historical outcome:
5 / 5 approved
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;With memory disabled:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;WRITTEN POLICY ONLY
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;The system must not use historical precedent when memory is off.&lt;/p&gt;

&lt;p&gt;This matters because a visual toggle is not enough by itself. The actual data flow has to respect the boundary.&lt;/p&gt;

&lt;p&gt;The same invoice therefore becomes a useful test:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;MEMORY ON
Policy + Historical Evidence

MEMORY OFF
Written Policy Only
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&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%2Fi8e9a26fevbeo9tftrdb.png" 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%2Fi8e9a26fevbeo9tftrdb.png" alt=" " width="395" height="832"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h2&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%2Fw3p0ra2t1fmk9rj45w5h.png" alt=" " width="391" height="516"&gt;
&lt;/h2&gt;

&lt;h2&gt;
  
  
  The no-history case
&lt;/h2&gt;

&lt;p&gt;A memory system also needs to handle the situation where there is no useful precedent.&lt;/p&gt;

&lt;p&gt;Echo has an explicit no-history state:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;NO INSTITUTIONAL PRECEDENT
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;In that situation, the system does not invent:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;historical cases&lt;/li&gt;
&lt;li&gt;approval counts&lt;/li&gt;
&lt;li&gt;conditions&lt;/li&gt;
&lt;li&gt;confidence&lt;/li&gt;
&lt;li&gt;past outcomes&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Instead, it falls back to the written policy.&lt;/p&gt;

&lt;p&gt;That gives the system a useful failure mode:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;No sufficient historical precedent was found.

Written policy remains the available guidance.
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;I consider that an important property of the architecture.&lt;/p&gt;

&lt;p&gt;An agent does not need to answer every historical question.&lt;/p&gt;

&lt;p&gt;Sometimes the correct answer is that the available memory is insufficient.&lt;/p&gt;




&lt;h2&gt;
  
  
  Learning from human decisions
&lt;/h2&gt;

&lt;p&gt;Memory is useful only if it can grow.&lt;/p&gt;

&lt;p&gt;When a human resolves an exception, Echo retains the new case and updates the corresponding pattern.&lt;/p&gt;

&lt;p&gt;The update flow is:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;Human resolution
       ↓
Retain new case
       ↓
Read current pattern
       ↓
Read supporting cases
       ↓
Add new case
       ↓
Recompute aggregate
       ↓
Store updated pattern
       ↓
Read back and verify
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;The pattern stores structured information such as:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;support count
approved count
rejected count
approvers
condition
policy route
last seen
supporting case IDs
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;The language model can explain those facts, but it does not become the source of those facts.&lt;/p&gt;

&lt;p&gt;That keeps the learning loop inspectable.&lt;/p&gt;




&lt;h2&gt;
  
  
  Echo Replay
&lt;/h2&gt;

&lt;p&gt;Echo Replay uses the same evidence model to compare historical precedent under different conditions.&lt;/p&gt;

&lt;p&gt;For example:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;Current condition:
fuel-surcharge annexure attached

Historical evidence:
5 comparable cases
5 approved
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;The user can then inspect an alternative condition.&lt;/p&gt;

&lt;p&gt;If historical precedent does not exist for that condition, Echo shows:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;No comparable historical precedent found.
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;It does not manufacture an approval or rejection merely because the condition changed.&lt;/p&gt;

&lt;p&gt;Absence of evidence remains absence of evidence.&lt;/p&gt;




&lt;h2&gt;
  
  
  Reflection is deliberately separated
&lt;/h2&gt;

&lt;p&gt;Hindsight also provides reflection capabilities.&lt;/p&gt;

&lt;p&gt;Echo has an opt-in reflection path for producing a concise synthesis of retrieved evidence.&lt;/p&gt;

&lt;p&gt;However, reflection is not treated as the source of structured truth.&lt;/p&gt;

&lt;p&gt;It should not determine:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;case identity
approval count
confidence
policy truth
historical outcome
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Those remain grounded in the historical memory and deterministic application logic.&lt;/p&gt;

&lt;p&gt;The responsibility boundary is:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;Hindsight
    ↓
Persistent memory

Deterministic Echo logic
    ↓
Evidence + confidence + comparability

LLM
    ↓
Explanation

Human
    ↓
Final decision
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;This separation made the system much easier to reason about.&lt;/p&gt;




&lt;h2&gt;
  
  
  What changed as the memory corpus grew
&lt;/h2&gt;

&lt;p&gt;The system started with a smaller verified set of historical cases.&lt;/p&gt;

&lt;p&gt;I then expanded the corpus with 150 additional structured cases covering:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;amount mismatches&lt;/li&gt;
&lt;li&gt;missing POs&lt;/li&gt;
&lt;li&gt;GST mismatches&lt;/li&gt;
&lt;li&gt;duplicate suspects&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;The expansion was validated before being seeded into Hindsight.&lt;/p&gt;

&lt;p&gt;Adding more memory did not simply make retrieval “better.”&lt;/p&gt;

&lt;p&gt;It also introduced a new problem.&lt;/p&gt;

&lt;p&gt;The larger the memory corpus became, the more likely it was that a new query could retrieve something that looked similar but belonged to a different policy regime or condition.&lt;/p&gt;

&lt;p&gt;That made the evidence boundary more important.&lt;/p&gt;

&lt;p&gt;The solution was not to give the language model more historical context.&lt;/p&gt;

&lt;p&gt;The solution was to give it a smaller and better-defined evidence window.&lt;/p&gt;




&lt;h2&gt;
  
  
  An honest engineering lesson
&lt;/h2&gt;

&lt;p&gt;One of the biggest lessons from building Echo was that persistent memory creates a second problem after solving the first one.&lt;/p&gt;

&lt;p&gt;The first problem is:&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;How do I remember what happened?&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;The second problem is:&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;How do I know whether what I remembered actually applies here?&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;Those are different engineering problems.&lt;/p&gt;

&lt;p&gt;The first needs persistent memory.&lt;/p&gt;

&lt;p&gt;The second needs deterministic rules.&lt;/p&gt;

&lt;p&gt;That distinction changed the architecture of Echo.&lt;/p&gt;

&lt;p&gt;Instead of:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;Retrieve everything
      ↓
Ask the LLM to decide
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;the system became:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;Retrieve
   ↓
Validate
   ↓
Compare
   ↓
Compute
   ↓
Explain
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;That extra boundary is what makes the memory useful without allowing memory itself to become an uncontrolled source of truth.&lt;/p&gt;




&lt;h2&gt;
  
  
  What I would reuse in another agent
&lt;/h2&gt;

&lt;h3&gt;
  
  
  1. Separate retrieval from evidence selection
&lt;/h3&gt;

&lt;p&gt;Semantic retrieval is useful for finding candidates.&lt;/p&gt;

&lt;p&gt;It should not automatically determine which candidates are valid evidence.&lt;/p&gt;

&lt;h3&gt;
  
  
  2. Keep confidence outside the LLM
&lt;/h3&gt;

&lt;p&gt;Counts, sample sizes, and evidence strength are easier to verify when they come from deterministic logic.&lt;/p&gt;

&lt;h3&gt;
  
  
  3. Store conditions alongside outcomes
&lt;/h3&gt;

&lt;p&gt;“Approved” is less useful than:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;Approved when the vendor annexure was attached.
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;The condition explains when historical behaviour occurred.&lt;/p&gt;

&lt;h3&gt;
  
  
  4. Treat no precedent as a valid result
&lt;/h3&gt;

&lt;p&gt;An agent should be able to say:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;No sufficient historical precedent was found.
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;rather than manufacturing a conclusion from unrelated memories.&lt;/p&gt;

&lt;h3&gt;
  
  
  5. Let human decisions become future memory
&lt;/h3&gt;

&lt;p&gt;The system becomes more useful when resolved cases can become part of its future institutional memory.&lt;/p&gt;




&lt;h2&gt;
  
  
  The architecture I would reuse
&lt;/h2&gt;

&lt;p&gt;The most reusable part of Echo is not the AP domain itself.&lt;/p&gt;

&lt;p&gt;It is the separation of responsibilities.&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%2Firqqjjmyyckwbhvx9n4g.png" 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%2Firqqjjmyyckwbhvx9n4g.png" alt=" " width="799" height="309"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;This pattern can extend beyond accounts payable.&lt;/p&gt;

&lt;p&gt;The domain can change.&lt;/p&gt;

&lt;p&gt;The responsibility boundaries can remain the same:&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;&lt;strong&gt;Memory preserves experience. Deterministic logic establishes evidence. Models explain the evidence. Humans make the final decision.&lt;/strong&gt;&lt;/p&gt;
&lt;/blockquote&gt;




&lt;h2&gt;
  
  
  Screenshots
&lt;/h2&gt;

&lt;p&gt;The screenshots are part of the technical story, not just decoration.&lt;/p&gt;

&lt;h3&gt;
  
  
  Investigation workspace
&lt;/h3&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%2F1xv5ljt28zszw8shs5fc.png" 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%2F1xv5ljt28zszw8shs5fc.png" alt=" " width="800" height="386"&gt;&lt;/a&gt;&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%2F27thi43ihm2wy3edf4i7.png" 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%2F27thi43ihm2wy3edf4i7.png" alt=" " width="799" height="212"&gt;&lt;/a&gt;&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%2F0fqt9k3oj5m7gu1696r0.png" 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%2F0fqt9k3oj5m7gu1696r0.png" alt=" " width="800" height="229"&gt;&lt;/a&gt;&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%2F4rmv60qurz53ngvaobbf.png" 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%2F4rmv60qurz53ngvaobbf.png" alt=" " width="789" height="170"&gt;&lt;/a&gt;&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%2Fohaitkcal8lutltvku0b.png" 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%2Fohaitkcal8lutltvku0b.png" alt=" " width="799" height="200"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h3&gt;
  
  
  Memory ON vs Memory OFF
&lt;/h3&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%2F940hmtcd8puox0uftfvv.png" 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%2F940hmtcd8puox0uftfvv.png" alt=" " width="395" height="832"&gt;&lt;/a&gt;&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%2Fhajtjb5ww3tofiflgwnd.png" 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%2Fhajtjb5ww3tofiflgwnd.png" alt=" " width="391" height="516"&gt;&lt;/a&gt;&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%2Fqqwtznvfp5akbtfs80b7.png" 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%2Fqqwtznvfp5akbtfs80b7.png" alt="Memory comparison" width="427" height="382"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h3&gt;
  
  
  Echo Replay
&lt;/h3&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%2Fxiqlbbh1vhpyg9nmnjtv.png" 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%2Fxiqlbbh1vhpyg9nmnjtv.png" alt=" " width="799" height="290"&gt;&lt;/a&gt;&lt;/p&gt;




&lt;h2&gt;
  
  
  Final thoughts
&lt;/h2&gt;

&lt;p&gt;I started Echo thinking that the interesting engineering problem would be giving an agent long-term memory.&lt;/p&gt;

&lt;p&gt;The harder problem turned out to be defining what that memory was actually allowed to prove.&lt;/p&gt;

&lt;p&gt;Hindsight gave Echo persistent institutional memory.&lt;/p&gt;

&lt;p&gt;The rest of the architecture determines how responsibly that memory is used.&lt;/p&gt;

&lt;p&gt;The result is not a database of answers.&lt;/p&gt;

&lt;p&gt;It is a system that remembers what happened, shows the conditions under which it happened, compares that history with written policy, and gives a human a clearer basis for the next decision.&lt;/p&gt;

&lt;p&gt;That is the part of agent memory I find most interesting:&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;&lt;strong&gt;Not remembering everything, but remembering enough to make the next decision better grounded.&lt;/strong&gt;&lt;/p&gt;
&lt;/blockquote&gt;

&lt;h2&gt;
  
  
  Project
&lt;/h2&gt;

&lt;p&gt;&lt;strong&gt;&lt;a href="https://github.com/MudadlaPranay12/echo" rel="noopener noreferrer"&gt;Echo — AP Exception Intelligence Agent&lt;/a&gt;&lt;/strong&gt;&lt;/p&gt;

&lt;h2&gt;
  
  
  Hindsight Resources
&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;&lt;a href="https://github.com/vectorize-io/hindsight" rel="noopener noreferrer"&gt;Hindsight GitHub Repository&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="https://hindsight.vectorize.io/" rel="noopener noreferrer"&gt;Hindsight Documentation&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="https://vectorize.io/what-is-agent-memory" rel="noopener noreferrer"&gt;Vectorize Agent Memory&lt;/a&gt;&lt;/li&gt;
&lt;/ul&gt;

</description>
      <category>agents</category>
      <category>ai</category>
      <category>architecture</category>
      <category>llm</category>
    </item>
  </channel>
</rss>
