<?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: Ali Baizhanov</title>
    <description>The latest articles on DEV Community by Ali Baizhanov (@alibaizhanov).</description>
    <link>https://dev.to/alibaizhanov</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%2F3779201%2F7ebda2f1-f677-4b9b-9506-94f1c75f88db.jpeg</url>
      <title>DEV Community: Ali Baizhanov</title>
      <link>https://dev.to/alibaizhanov</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://dev.to/feed/alibaizhanov"/>
    <language>en</language>
    <item>
      <title>Our Monitoring Said 62% of Retrievals Were Failing. The Bug Was Two Score Scales in One Column.</title>
      <dc:creator>Ali Baizhanov</dc:creator>
      <pubDate>Thu, 23 Jul 2026 10:48:13 +0000</pubDate>
      <link>https://dev.to/alibaizhanov/our-monitoring-said-62-of-retrievals-were-failing-the-bug-was-two-score-scales-in-one-column-j1d</link>
      <guid>https://dev.to/alibaizhanov/our-monitoring-said-62-of-retrievals-were-failing-the-bug-was-two-score-scales-in-one-column-j1d</guid>
      <description>&lt;h2&gt;
  
  
  The scare
&lt;/h2&gt;

&lt;p&gt;Hybrid retrieval over personal memory — vector similarity + BM25, fused with Reciprocal Rank Fusion, optional cross-encoder rerank on some tiers. Every search logs &lt;code&gt;top_score&lt;/code&gt; for quality monitoring. Analyzing 10,706 logged searches, I applied the obvious threshold — &lt;code&gt;top_score &amp;lt; 0.3&lt;/code&gt; = weak retrieval. Result: 62% "failures," a dozen users at "100% failure with avg score 0.017," and a terrifying month-over-month "degradation." One of the "100% failed" users was a paying customer with a thousand searches. I was halfway into incident mode.&lt;/p&gt;

&lt;h2&gt;
  
  
  The tell
&lt;/h2&gt;

&lt;p&gt;A search for an exact entity name — a guaranteed hit — logged top_score 0.0426. And the "failing" users all averaged 0.016–0.021. Then it clicked: RRF scores are &lt;code&gt;1/(k + rank)&lt;/code&gt; with the standard k=60. Top rank = 1/60 ≈ 0.0167. My "catastrophic" users weren't failing — &lt;strong&gt;their top result was rank-1 almost every time.&lt;/strong&gt; An average of 0.017 is what &lt;em&gt;perfect&lt;/em&gt; RRF retrieval looks like.&lt;/p&gt;

&lt;h2&gt;
  
  
  What actually happened
&lt;/h2&gt;

&lt;p&gt;Requests that go through the reranker log cosine-style scores (0–1 scale, 0.3+ = good). Requests on the raw RRF path log fusion scores (0.016–0.05 scale, where 0.017 = excellent). Both landed in the same &lt;code&gt;top_score&lt;/code&gt; column with no scale tag. Every aggregate over that column — means, z-scores, my failure thresholds, even the health-monitoring cron — was averaging apples with orbital velocities. The "month-over-month degradation" was just the RRF-path share growing as more traffic moved to hybrid.&lt;/p&gt;

&lt;p&gt;What survived scale-correction: true failure (zero results) was 9–13%, driven mostly by two accounts whose agents were querying literally empty stores — a real problem, but a completely different one than "retrieval is broken."&lt;/p&gt;

&lt;h2&gt;
  
  
  Lessons that generalize
&lt;/h2&gt;

&lt;ol&gt;
&lt;li&gt;
&lt;strong&gt;A fused ranking score is not a similarity.&lt;/strong&gt; RRF outputs rank information, not confidence. The moment you fuse, the score's absolute value stops meaning what your dashboards think it means.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Never store scores from different scoring regimes in one unlabeled column.&lt;/strong&gt; Log a &lt;code&gt;score_kind&lt;/code&gt; (or a scale-aware quality label computed at write time) — analysis-time guessing is how you get 3am false incidents.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;The only scale-free failure signal is emptiness.&lt;/strong&gt; Zero results means the same thing on every path. When in doubt, count zeros, not thresholds.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Validate your alarm against a known-good query before believing it.&lt;/strong&gt; One exact-match search that "scored 0.04" saved me from paging myself.&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;The k=60 default everyone inherits comes from Cormack, Clarke &amp;amp; Buettcher (2009), "Reciprocal Rank Fusion outperforms Condorcet and individual rank learning methods." The trap applies to any RAG stack mixing rerankers with fusion scoring — grep your score column and look for a bimodal cluster around 1/60.&lt;/p&gt;




&lt;p&gt;&lt;em&gt;I build &lt;a href="https://mengram.io" rel="noopener noreferrer"&gt;Mengram&lt;/a&gt;, a memory layer for AI agents. The fix — a scale-aware quality label written alongside every search — is in the public commit history. Questions welcome.&lt;/em&gt;&lt;/p&gt;

</description>
      <category>rag</category>
      <category>postgres</category>
      <category>ai</category>
      <category>webdev</category>
    </item>
    <item>
      <title>Claude Code Forgets Everything After Compaction. Here's the Fix That Survives It</title>
      <dc:creator>Ali Baizhanov</dc:creator>
      <pubDate>Wed, 22 Jul 2026 10:22:49 +0000</pubDate>
      <link>https://dev.to/alibaizhanov/claude-code-forgets-everything-after-compaction-heres-the-fix-that-survives-it-37a7</link>
      <guid>https://dev.to/alibaizhanov/claude-code-forgets-everything-after-compaction-heres-the-fix-that-survives-it-37a7</guid>
      <description>&lt;h2&gt;
  
  
  The problem: compaction is amnesia by design
&lt;/h2&gt;

&lt;p&gt;When a Claude Code session approaches its context limit, &lt;strong&gt;auto-compact&lt;/strong&gt; summarizes the conversation and throws away the original. It has to — context windows are finite. But what survives is a summary written under token pressure, and what dies is exactly the stuff you needed: the decision you made an hour ago, the constraint you stated once, the approach you already rejected twice.&lt;/p&gt;

&lt;p&gt;This isn't a niche complaint. On Anthropic's own issue tracker: &lt;a href="https://github.com/anthropics/claude-code/issues/17428" rel="noopener noreferrer"&gt;enhanced /compact with restorable summaries&lt;/a&gt; (114 upvotes), &lt;a href="https://github.com/anthropics/claude-code/issues/27242" rel="noopener noreferrer"&gt;no way to review context after compaction&lt;/a&gt; (79), &lt;a href="https://github.com/anthropics/claude-code/issues/7502" rel="noopener noreferrer"&gt;auto-compact erases chat history without warning&lt;/a&gt; (35), and — the quiet killer — &lt;a href="https://github.com/anthropics/claude-code/issues/6354" rel="noopener noreferrer"&gt;Claude forgets CLAUDE.md guidance after compaction&lt;/a&gt; (28). Hundreds of developers voting on the same wound.&lt;/p&gt;

&lt;h2&gt;
  
  
  Why CLAUDE.md doesn't save you
&lt;/h2&gt;

&lt;p&gt;The standard advice is "put important context in CLAUDE.md." It helps — until it doesn't. CLAUDE.md is static: it holds what you remembered to write down last week, not the decision from forty minutes ago that compaction just ate. And per the issue above, even CLAUDE.md guidance &lt;em&gt;itself&lt;/em&gt; loses force after heavy compaction as the summary crowds it out.&lt;/p&gt;

&lt;h2&gt;
  
  
  What actually survives: memory outside the context window
&lt;/h2&gt;

&lt;p&gt;The durable fix is structural: keep the important state &lt;strong&gt;outside&lt;/strong&gt; the thing that gets compacted, and re-inject it on every fresh start. Claude Code has the exact machinery for this — the &lt;code&gt;SessionStart&lt;/code&gt; hook fires not just on startup, but also on &lt;code&gt;/clear&lt;/code&gt;, resume, &lt;em&gt;and after compaction&lt;/em&gt;.&lt;/p&gt;

&lt;p&gt;That's how the &lt;a href="https://mengram.io" rel="noopener noreferrer"&gt;Mengram&lt;/a&gt; plugin makes context survive compaction:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;During the session&lt;/strong&gt;, a Stop hook captures each turn in the background — facts, decisions, and workflows get extracted into persistent memory (API keys and tokens are redacted client-side).&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;After compaction&lt;/strong&gt; (or /clear, or a new session, or a different machine), the SessionStart hook reloads your cognitive profile — who you are, what you're building, what you decided — as fresh context. The summary can be lossy; the memory isn't.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;On every prompt&lt;/strong&gt;, relevant past context is recalled and injected, so "how did we deploy this again?" gets answered from memory instead of re-derived.&lt;/li&gt;
&lt;/ul&gt;

&lt;h2&gt;
  
  
  Setup (60 seconds)
&lt;/h2&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;&lt;span class="c"&gt;# 1. Free API key: https://mengram.io — save it once&lt;/span&gt;
&lt;span class="nb"&gt;mkdir&lt;/span&gt; &lt;span class="nt"&gt;-p&lt;/span&gt; ~/.mengram &lt;span class="o"&gt;&amp;amp;&amp;amp;&lt;/span&gt; &lt;span class="nb"&gt;echo&lt;/span&gt; &lt;span class="s1"&gt;'{"api_key": "om-your-key"}'&lt;/span&gt; &lt;span class="o"&gt;&amp;gt;&lt;/span&gt; ~/.mengram/config.json

&lt;span class="c"&gt;# 2. Install the plugin&lt;/span&gt;
claude plugin marketplace add alibaizhanov/mengram
claude plugin &lt;span class="nb"&gt;install &lt;/span&gt;mengram@mengram

&lt;span class="c"&gt;# 3. Optional: feed in your existing session history (secrets redacted locally)&lt;/span&gt;
pip &lt;span class="nb"&gt;install &lt;/span&gt;mengram-ai &lt;span class="o"&gt;&amp;amp;&amp;amp;&lt;/span&gt; mengram import claude-code
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Test it: tell Claude something about your project, run /compact (or /clear), and ask again. The context comes back — not from the summary, but from memory.&lt;/p&gt;

&lt;p&gt;What this doesn't fix&lt;/p&gt;

&lt;p&gt;Honesty section: no external memory restores the full pre-compact transcript — that's gone, and tools claiming otherwise are re-summarizing too. What persistent memory changes is which things survive: instead of whatever the compactor kept under pressure, you keep structured facts, decisions, and workflows extracted while they were fresh. For the transcript itself, vote on #17428 (&lt;a href="https://github.com/anthropics/claude-code/issues/17428" rel="noopener noreferrer"&gt;https://github.com/anthropics/claude-code/issues/17428&lt;/a&gt;) — file-backed summaries would compose beautifully with external memory.&lt;/p&gt;




&lt;p&gt;I'm the founder of Mengram (&lt;a href="https://mengram.io" rel="noopener noreferrer"&gt;https://mengram.io&lt;/a&gt;) — a memory layer for AI agents (semantic facts + episodic events + procedural workflows that evolve from failures). Free tier, self-hostable, Apache 2.0. Questions welcome in the comments.&lt;/p&gt;

</description>
      <category>ai</category>
      <category>claude</category>
      <category>productivity</category>
      <category>devtools</category>
    </item>
    <item>
      <title>How to Give Claude Code Persistent Memory (2 Commands)</title>
      <dc:creator>Ali Baizhanov</dc:creator>
      <pubDate>Fri, 20 Mar 2026 13:07:00 +0000</pubDate>
      <link>https://dev.to/alibaizhanov/how-to-give-claude-code-persistent-memory-2-commands-19hf</link>
      <guid>https://dev.to/alibaizhanov/how-to-give-claude-code-persistent-memory-2-commands-19hf</guid>
      <description>&lt;p&gt;Claude Code is incredible for coding — but it starts fresh every session. It doesn't know you used Railway yesterday, that you prefer Sora over Inter, or that you spent 3 hours debugging that psycopg2 pool deadlock last week.&lt;/p&gt;

&lt;p&gt;Here's how to fix that in 2 commands.&lt;/p&gt;

&lt;h2&gt;
  
  
  Setup (30 seconds)
&lt;/h2&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;pip &lt;span class="nb"&gt;install &lt;/span&gt;mengram-ai
mengram setup
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;code&gt;mengram setup&lt;/code&gt; creates a free account and installs Claude Code hooks. That's it.&lt;/p&gt;

&lt;h2&gt;
  
  
  What happens next
&lt;/h2&gt;

&lt;p&gt;Every Claude Code session now does this automatically:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;Session Start  →  Loads your cognitive profile (who you are, tech stack, preferences)
Every Prompt   →  Searches past sessions for relevant context
After Response →  Saves new knowledge in background
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;No manual saves. No tool calls. No MCP configuration. Claude just remembers.&lt;/p&gt;

&lt;h2&gt;
  
  
  What it actually remembers
&lt;/h2&gt;

&lt;p&gt;Mengram stores 3 types of memory — not just facts:&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Semantic memory&lt;/strong&gt; — facts and preferences:&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;"Uses Python 3.12, deploys to Railway, prefers PostgreSQL over MySQL"&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;&lt;strong&gt;Episodic memory&lt;/strong&gt; — events and decisions:&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;"March 15: Debugged pool deadlock, fixed by increasing pool_max from 2 to 5"&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;&lt;strong&gt;Procedural memory&lt;/strong&gt; — workflows that evolve:&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;"Deploy flow: git push → Railway auto-deploys from main → check logs"&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;The procedural part is key: if a workflow fails, Mengram updates the procedure with what went wrong and how you fixed it. Next time Claude encounters a similar task, it already knows the correct approach.&lt;/p&gt;

&lt;h2&gt;
  
  
  Quick example
&lt;/h2&gt;

&lt;p&gt;After a few sessions, Claude Code builds a cognitive profile of you:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight json"&gt;&lt;code&gt;&lt;span class="s2"&gt;"Ali is a solo founder building Mengram. Uses Python/Flask on Railway
with Supabase PostgreSQL. Prefers concise code, avoids over-engineering.
Uses gunicorn with 1 worker. Common issues: psycopg2 pool sizing,
OpenAI API rate limits."&lt;/span&gt;&lt;span class="w"&gt;
&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;When you start a new session and say "fix the deploy", Claude already knows your stack, your deploy process, and what went wrong last time.&lt;/p&gt;

&lt;h2&gt;
  
  
  How it works under the hood
&lt;/h2&gt;

&lt;p&gt;Mengram uses &lt;a href="https://docs.anthropic.com/en/docs/claude-code/hooks" rel="noopener noreferrer"&gt;Claude Code hooks&lt;/a&gt; — shell commands that run at specific lifecycle points:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;PreToolUse&lt;/strong&gt; — before each prompt, searches your memory for relevant context&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;PostToolUse&lt;/strong&gt; — after each response, extracts and saves new knowledge&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;SessionStart&lt;/strong&gt; — loads your cognitive profile into the system prompt&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;All data goes to Mengram's API where it's chunked, embedded, and stored in a knowledge graph. Search uses hybrid retrieval (vector + graph traversal + reranking).&lt;/p&gt;

&lt;h2&gt;
  
  
  Beyond Claude Code
&lt;/h2&gt;

&lt;p&gt;Same API works with any AI tool:&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;from&lt;/span&gt; &lt;span class="n"&gt;mengram&lt;/span&gt; &lt;span class="kn"&gt;import&lt;/span&gt; &lt;span class="n"&gt;Mengram&lt;/span&gt;
&lt;span class="n"&gt;m&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nc"&gt;Mengram&lt;/span&gt;&lt;span class="p"&gt;()&lt;/span&gt;

&lt;span class="c1"&gt;# Store a conversation
&lt;/span&gt;&lt;span class="n"&gt;m&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;add&lt;/span&gt;&lt;span class="p"&gt;([&lt;/span&gt;
    &lt;span class="p"&gt;{&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt;role&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt;user&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt;content&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt;Deploy the app to production&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="p"&gt;},&lt;/span&gt;
    &lt;span class="p"&gt;{&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt;role&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt;assistant&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt;content&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt;Pushed to main, Railway auto-deployed. Took 45s.&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="p"&gt;}&lt;/span&gt;
&lt;span class="p"&gt;])&lt;/span&gt;

&lt;span class="c1"&gt;# Later, in a different session
&lt;/span&gt;&lt;span class="n"&gt;results&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;m&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;search&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt;how do I deploy?&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;span class="c1"&gt;# → Returns the deploy procedure + past deployment events
&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Works with &lt;strong&gt;MCP&lt;/strong&gt; (29 tools), &lt;strong&gt;LangChain&lt;/strong&gt;, &lt;strong&gt;CrewAI&lt;/strong&gt;, &lt;strong&gt;OpenClaw&lt;/strong&gt;, and plain REST API.&lt;/p&gt;

&lt;h2&gt;
  
  
  Pricing
&lt;/h2&gt;

&lt;p&gt;Free tier: 50 adds/month, 300 searches. Enough for personal use. Paid plans start at $5/mo.&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Docs: &lt;a href="https://docs.mengram.io" rel="noopener noreferrer"&gt;docs.mengram.io&lt;/a&gt;
&lt;/li&gt;
&lt;li&gt;GitHub: &lt;a href="https://github.com/alibaizhanov/mengram" rel="noopener noreferrer"&gt;github.com/alibaizhanov/mengram&lt;/a&gt;
&lt;/li&gt;
&lt;li&gt;Website: &lt;a href="https://mengram.io" rel="noopener noreferrer"&gt;mengram.io&lt;/a&gt;
&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Open source, Apache 2.0.&lt;/p&gt;

</description>
      <category>claudecode</category>
      <category>ai</category>
      <category>opensource</category>
      <category>openclaw</category>
    </item>
    <item>
      <title>I built an AI memory API with 3 memory types — here's why facts alone aren't enough published</title>
      <dc:creator>Ali Baizhanov</dc:creator>
      <pubDate>Wed, 18 Feb 2026 10:08:31 +0000</pubDate>
      <link>https://dev.to/alibaizhanov/i-built-an-ai-memory-api-with-3-memory-types-heres-why-facts-alone-arent-enoughpublished-4ofn</link>
      <guid>https://dev.to/alibaizhanov/i-built-an-ai-memory-api-with-3-memory-types-heres-why-facts-alone-arent-enoughpublished-4ofn</guid>
      <description>&lt;p&gt;Every AI memory tool I tried had the same problem: they only store facts.&lt;/p&gt;

&lt;p&gt;"User likes Python." "User lives in Almaty." Cool. But human memory doesn't work like that. We have three types:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;Semantic&lt;/strong&gt; — facts and knowledge ("Python is a programming language")&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Episodic&lt;/strong&gt; — events and experiences ("I spent 3 hours debugging that auth bug last Tuesday")&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Procedural&lt;/strong&gt; — how to do things ("Deploy: build → upload → push → verify")&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;I built &lt;a href="https://mengram.io" rel="noopener noreferrer"&gt;Mengram&lt;/a&gt; to give AI all three. Here's what I learned building it.&lt;/p&gt;

&lt;h2&gt;
  
  
  The Problem
&lt;/h2&gt;

&lt;p&gt;I was building AI agents that needed to remember things across sessions. Tried Mem0, tried rolling my own with pgvector. Same issue every time:&lt;/p&gt;

&lt;p&gt;My agent could remember that I use Railway for hosting. But it couldn't remember that last Friday's deploy broke because I forgot to run migrations. And it definitely couldn't remember that the correct deploy process is: test → build → push → migrate → verify.&lt;/p&gt;

&lt;p&gt;That's three different kinds of memory, and every existing tool only handles the first one.&lt;/p&gt;

&lt;h2&gt;
  
  
  The Solution: 3 Memory Types from 1 API Call
&lt;/h2&gt;

&lt;p&gt;Mengram extracts all three types automatically:&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;from&lt;/span&gt; &lt;span class="n"&gt;mengram.cloud.client&lt;/span&gt; &lt;span class="kn"&gt;import&lt;/span&gt; &lt;span class="n"&gt;CloudMemory&lt;/span&gt;

&lt;span class="n"&gt;m&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nc"&gt;CloudMemory&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="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt;om-...&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;

&lt;span class="n"&gt;m&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;add&lt;/span&gt;&lt;span class="p"&gt;([&lt;/span&gt;
    &lt;span class="p"&gt;{&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt;role&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt;user&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt;content&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt;Fixed the auth bug today. The problem was API key cache TTL was set to 0. My debug process: check Railway logs, reproduce locally, fix and deploy.&lt;/span&gt;&lt;span class="sh"&gt;"&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;One call. Mengram's LLM extraction pipeline produces:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;Semantic:&lt;/strong&gt; "API key cache TTL of 0 caused auth bug"&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Episodic:&lt;/strong&gt; "Debugged auth bug, root cause was cache TTL, fixed and deployed"&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Procedural:&lt;/strong&gt; "Debug process: check logs → reproduce locally → fix → deploy"&lt;/li&gt;
&lt;/ul&gt;

&lt;h2&gt;
  
  
  The Killer Feature: Procedural Learning
&lt;/h2&gt;

&lt;p&gt;This is what no competitor has.&lt;/p&gt;

&lt;p&gt;Your AI agent completes a multi-step task. Mengram saves the steps as a procedure with success/failure tracking. Next time a similar task comes up, the agent already knows the optimal path.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;Day 1: Agent figures out deployment
  → test → build → push → migrate → verify
  → Mengram saves as procedure (1 success, 0 failures)

Day 5: Agent deploys again  
  → Finds procedure in memory
  → Follows proven path
  → Records success (2 successes, 0 failures)

Day 12: Agent skips tests, deploy breaks
  → Records failure (2 successes, 1 failure)
  → Next time: "This procedure works better with tests first"
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;The AI literally learns from its own experience. Not from fine-tuning, not from few-shot examples — from actual procedural memory.&lt;/p&gt;

&lt;h2&gt;
  
  
  Smart Triggers: Memory That Raises Its Hand
&lt;/h2&gt;

&lt;p&gt;Most memory is passive — you ask, it answers. Mengram also has proactive memory:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;Reminders:&lt;/strong&gt; "You mentioned a meeting with Anya tomorrow at 3pm" → fires webhook 1 hour before&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Contradictions:&lt;/strong&gt; Memory says "Anya is vegetarian" → you say "order steaks for dinner with Anya" → alert&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Patterns:&lt;/strong&gt; 3 out of 5 Friday deploys had bugs → "Maybe wait until Monday?"&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;These fire automatically via webhooks — works with Slack, Discord, OpenClaw, or any endpoint.&lt;/p&gt;

&lt;h2&gt;
  
  
  Integrations
&lt;/h2&gt;

&lt;p&gt;Mengram works as a memory layer for any AI stack:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;Claude Desktop&lt;/strong&gt; — MCP server, just add to config&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;LangChain&lt;/strong&gt; — drop-in &lt;code&gt;MengramMemory&lt;/code&gt; class replacing &lt;code&gt;ConversationBufferMemory&lt;/code&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;CrewAI&lt;/strong&gt; — 5 tools including &lt;code&gt;mengram_save_workflow&lt;/code&gt; for procedural learning&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;OpenClaw&lt;/strong&gt; — skill on ClawHub with bash scripts for all channels&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Any LLM&lt;/strong&gt; — REST API + Python/JS SDKs
&lt;/li&gt;
&lt;/ul&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;pip &lt;span class="nb"&gt;install &lt;/span&gt;mengram-ai    &lt;span class="c"&gt;# Python&lt;/span&gt;
npm &lt;span class="nb"&gt;install &lt;/span&gt;mengram-ai    &lt;span class="c"&gt;# JavaScript&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h2&gt;
  
  
  Cognitive Profile
&lt;/h2&gt;

&lt;p&gt;One API call generates a system prompt from everything Mengram knows about a user:&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;profile&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;m&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;get_profile&lt;/span&gt;&lt;span class="p"&gt;()&lt;/span&gt;
&lt;span class="nf"&gt;print&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;profile&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt;system_prompt&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="p"&gt;])&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;





&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;You are talking to Ali, a 22-year-old developer in Almaty building Mengram.
He uses Python, PostgreSQL, and Railway. Recently: debugged pgvector deployment,
researched competitors. Workflows: deploys via build→twine→npm→git.
Communicate in Russian/English, direct style, focus on practical next steps.
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Insert into any LLM for instant personalization. Replaces your RAG pipeline.&lt;/p&gt;

&lt;h2&gt;
  
  
  Architecture
&lt;/h2&gt;

&lt;p&gt;Built on PostgreSQL + pgvector. No separate vector database needed.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;Your AI Client (Claude, GPT, any LLM)
    │
    ▼
Mengram Cloud API
    ├── LLM Extraction (entities, episodes, procedures)
    ├── Embedding (OpenAI text-embedding-3-large)
    ├── Hybrid Search (vector + full-text + re-ranking)
    ├── Smart Triggers (reminders, contradictions, patterns)
    └── Memory Agents (Curator, Connector, Digest)
    │
    ▼
PostgreSQL + pgvector
    ├── Entities &amp;amp; Facts (semantic)
    ├── Episodes (episodic)
    ├── Procedures (procedural)
    └── Embeddings (1536-dim vectors)
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h2&gt;
  
  
  What I Learned
&lt;/h2&gt;

&lt;p&gt;&lt;strong&gt;1. Extraction is everything.&lt;/strong&gt; The quality of your memory system depends entirely on how well you extract structured data from conversations. I went through 3 versions of the extraction prompt before it reliably separated facts from events from procedures.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;2. Contradiction detection is harder than it sounds.&lt;/strong&gt; "I'm vegetarian" and "I love steak" — obvious contradiction. "I prefer dark mode" and "I switched to light mode" — is that a contradiction or an update? LLM-based conflict resolution was the answer.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;3. Procedural memory is the moat.&lt;/strong&gt; Every competitor does semantic memory. Some do episodic. Nobody does procedural with success/failure tracking. This is what makes agents genuinely learn from experience.&lt;/p&gt;

&lt;h2&gt;
  
  
  Try It
&lt;/h2&gt;

&lt;p&gt;Free tier, no credit card, 60-second setup:&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;Sign up at &lt;a href="https://mengram.io" rel="noopener noreferrer"&gt;mengram.io&lt;/a&gt;
&lt;/li&gt;
&lt;li&gt;&lt;code&gt;pip install mengram-ai&lt;/code&gt;&lt;/li&gt;
&lt;li&gt;Start adding memories&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;Open source (Apache 2.0): &lt;a href="https://github.com/AiBaizhanov/mengram" rel="noopener noreferrer"&gt;github.com/AiBaizhanov/mengram&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;API docs: &lt;a href="https://mengram.io/docs" rel="noopener noreferrer"&gt;mengram.io/docs&lt;/a&gt;&lt;/p&gt;




&lt;p&gt;I'd love feedback — especially from anyone building AI agents. What memory challenges are you running into?&lt;/p&gt;

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