<?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: geco</title>
    <description>The latest articles on DEV Community by geco (@geco_50).</description>
    <link>https://dev.to/geco_50</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%2F1822586%2Ffb1d7f3d-6ec1-405b-8a28-fa101ed0523b.jpeg</url>
      <title>DEV Community: geco</title>
      <link>https://dev.to/geco_50</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://dev.to/feed/geco_50"/>
    <language>en</language>
    <item>
      <title>A failed compaction wiped my AI session, so I built it infinite memory</title>
      <dc:creator>geco</dc:creator>
      <pubDate>Thu, 17 Sep 2026 15:16:12 +0000</pubDate>
      <link>https://dev.to/geco_50/a-failed-compaction-wiped-my-ai-session-so-i-built-it-infinite-memory-18ie</link>
      <guid>https://dev.to/geco_50/a-failed-compaction-wiped-my-ai-session-so-i-built-it-infinite-memory-18ie</guid>
      <description>&lt;p&gt;It was a Tuesday morning. My OpenCode session had 378,755 tokens of context — weeks of trading-bot work. I hit &lt;code&gt;/compact&lt;/code&gt;. The model choked: &lt;strong&gt;3 output tokens, empty summary, &lt;code&gt;finish: length&lt;/code&gt;&lt;/strong&gt;. The compaction had failed, and the memory plugin I was using stored everything &lt;em&gt;inside&lt;/em&gt; that same compaction call. Result: total amnesia. Zero memories. The session was effectively lobotomized.&lt;/p&gt;

&lt;p&gt;That failure taught me the one design rule that matters for agent memory: &lt;strong&gt;never store memories only inside the compaction call&lt;/strong&gt;. Save incrementally, while you work — so a failed compaction costs you a summary, not your past.&lt;/p&gt;

&lt;p&gt;So I built &lt;a href="https://github.com/geco/opencode-mempalace-persistence" rel="noopener noreferrer"&gt;opencode-mempalace-persistence&lt;/a&gt; (v2.1.0, MIT) on top of &lt;a href="https://github.com/MemPalace/mempalace" rel="noopener noreferrer"&gt;MemPalace&lt;/a&gt;: every conversation is auto-saved to a local vector palace — zero cloud — and injected back into future prompts, across compactions &lt;em&gt;and&lt;/em&gt; across sessions.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto/https%3A%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Farticles%2Fg8wrmqhocz9ugdpw8vzf.gif" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto/https%3A%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Farticles%2Fg8wrmqhocz9ugdpw8vzf.gif" alt="Demo: a decision filed on Monday is recalled verbatim by a different session on Thursday" width="760" height="480"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h2&gt;
  
  
  How it works
&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;Auto-inject recall&lt;/strong&gt; — identity + relevant memories land in every prompt via &lt;code&gt;experimental.chat.messages.transform&lt;/code&gt;. Zero model discipline required.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;AI checkpoints&lt;/strong&gt; — every 15 messages the model files topics, decisions and quotes via MemPalace MCP tools (diary + knowledge graph). The hook decides &lt;em&gt;when&lt;/em&gt;, the model decides &lt;em&gt;what&lt;/em&gt; — same pattern as the official Claude Code hooks.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Pre-compaction emergency save&lt;/strong&gt; — before every compaction, everything essential is filed first, and core memory is re-attached to the summary so it survives.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Exit save&lt;/strong&gt; — quitting (even Ctrl+C) mines the last turns synchronously.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Per-project wings&lt;/strong&gt; — &lt;code&gt;bot-api&lt;/code&gt; sessions never leak into &lt;code&gt;mobile-app&lt;/code&gt; memories.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Backfill&lt;/strong&gt; — &lt;code&gt;OPENCODE_MEMPALACE_BACKFILL=1&lt;/code&gt; mines your full history once (I backfilled 9,448 messages / 1,735 drawers from a dead session).&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Bundled recall skill&lt;/strong&gt; — question-driven search-before-answer protocol, adapted from the official MemPalace skill. Search results are quoted &lt;strong&gt;verbatim&lt;/strong&gt;, never paraphrased.&lt;/li&gt;
&lt;/ul&gt;

&lt;h2&gt;
  
  
  Install (3 steps)
&lt;/h2&gt;

&lt;p&gt;&lt;strong&gt;1. Install MemPalace:&lt;/strong&gt;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;uv tool &lt;span class="nb"&gt;install&lt;/span&gt; &lt;span class="s2"&gt;"mempalace&amp;gt;=3.3.5"&lt;/span&gt;
mempalace init ~/opencode-memory
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;strong&gt;2. Plugin + MCP server&lt;/strong&gt; in &lt;code&gt;~/.config/opencode/opencode.json&lt;/code&gt;:&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="p"&gt;{&lt;/span&gt;&lt;span class="w"&gt;
  &lt;/span&gt;&lt;span class="nl"&gt;"plugin"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="s2"&gt;"opencode-mempalace-persistence"&lt;/span&gt;&lt;span class="p"&gt;],&lt;/span&gt;&lt;span class="w"&gt;
  &lt;/span&gt;&lt;span class="nl"&gt;"mcp"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="p"&gt;{&lt;/span&gt;&lt;span class="w"&gt;
    &lt;/span&gt;&lt;span class="nl"&gt;"mempalace"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="p"&gt;{&lt;/span&gt;&lt;span class="w"&gt;
      &lt;/span&gt;&lt;span class="nl"&gt;"type"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="s2"&gt;"local"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="w"&gt;
      &lt;/span&gt;&lt;span class="nl"&gt;"command"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="s2"&gt;"mempalace-mcp"&lt;/span&gt;&lt;span class="p"&gt;],&lt;/span&gt;&lt;span class="w"&gt;
      &lt;/span&gt;&lt;span class="nl"&gt;"enabled"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="kc"&gt;true&lt;/span&gt;&lt;span class="w"&gt;
    &lt;/span&gt;&lt;span class="p"&gt;}&lt;/span&gt;&lt;span class="w"&gt;
  &lt;/span&gt;&lt;span class="p"&gt;}&lt;/span&gt;&lt;span class="w"&gt;
&lt;/span&gt;&lt;span class="p"&gt;}&lt;/span&gt;&lt;span class="w"&gt;
&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;strong&gt;3. Identity&lt;/strong&gt; in &lt;code&gt;~/.mempalace/identity.txt&lt;/code&gt; (two lines about you), restart OpenCode. Done — from here it saves on its own: every 15 messages, on idle, on exit, before every compaction.&lt;/p&gt;

&lt;h2&gt;
  
  
  Why MemPalace and not summaries?
&lt;/h2&gt;

&lt;p&gt;Summarizers distill and discard. MemPalace stores the &lt;strong&gt;verbatim&lt;/strong&gt; transcript plus a knowledge graph with time-valid facts (&lt;code&gt;kg_supersede&lt;/code&gt;/&lt;code&gt;kg_invalidate&lt;/code&gt; when the world changes). When a new session asks "why does auth use Postgres instead of Redis?", it gets the original decision with its reasoning — including the part where the engineer who decided it is on holiday.&lt;/p&gt;

&lt;h2&gt;
  
  
  Links
&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;GitHub: &lt;a href="https://github.com/geco/opencode-mempalace-persistence" rel="noopener noreferrer"&gt;https://github.com/geco/opencode-mempalace-persistence&lt;/a&gt;
&lt;/li&gt;
&lt;li&gt;npm: &lt;a href="https://www.npmjs.com/package/opencode-mempalace-persistence" rel="noopener noreferrer"&gt;https://www.npmjs.com/package/opencode-mempalace-persistence&lt;/a&gt;
&lt;/li&gt;
&lt;li&gt;MemPalace: &lt;a href="https://github.com/MemPalace/mempalace" rel="noopener noreferrer"&gt;https://github.com/MemPalace/mempalace&lt;/a&gt;
&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;If you use OpenCode and compaction anxiety keeps you up at night, give it a try — issues and PRs welcome. What memory setup are &lt;em&gt;you&lt;/em&gt; running? I'm genuinely curious what survives in other people's stacks.&lt;/p&gt;

</description>
      <category>showdev</category>
      <category>ai</category>
      <category>opensource</category>
      <category>tutorial</category>
    </item>
  </channel>
</rss>
