<?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: Matchiffo Ynna</title>
    <description>The latest articles on DEV Community by Matchiffo Ynna (@matchiffo_ynna_459a16f5d7).</description>
    <link>https://dev.to/matchiffo_ynna_459a16f5d7</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%2F4234085%2F6640db5a-ec15-4573-ab7b-59c80fbed3ce.png</url>
      <title>DEV Community: Matchiffo Ynna</title>
      <link>https://dev.to/matchiffo_ynna_459a16f5d7</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://dev.to/feed/matchiffo_ynna_459a16f5d7"/>
    <language>en</language>
    <item>
      <title>Negative Memory: Teaching AI Agents What Not To Do</title>
      <dc:creator>Matchiffo Ynna</dc:creator>
      <pubDate>Sun, 08 Nov 2026 20:27:19 +0000</pubDate>
      <link>https://dev.to/matchiffo_ynna_459a16f5d7/negative-memory-teaching-ai-agents-what-not-to-do-5e3h</link>
      <guid>https://dev.to/matchiffo_ynna_459a16f5d7/negative-memory-teaching-ai-agents-what-not-to-do-5e3h</guid>
      <description>&lt;p&gt;Most agent memory is about success. We store the fix that worked, the query that returned the right rows, the prompt that produced a clean answer, and we retrieve it next time. That is useful, but it leaves out half of what an experienced engineer actually knows: the list of things that looked reasonable and went badly.&lt;/p&gt;

&lt;p&gt;Ask a new on-call engineer to fix a stuck service and they may restart it. Ask a senior one and they will first check whether a restart on that service drops in-flight payments. The difference is not more positive knowledge. It is a memory of past failures. AI agents today mostly do not have that, so they repeat the same ineffective or dangerous steps: the rollback that corrupted a migration last month, the cache flush that took the site down, the "quick restart" that lost queued jobs.&lt;/p&gt;

&lt;p&gt;Negative memory is the fix for this. The agent keeps a record of actions that failed or caused harm, and it reads that record before acting.&lt;/p&gt;

&lt;h2&gt;
  
  
  What a negative memory entry looks like
&lt;/h2&gt;

&lt;p&gt;Keep it small and structured. An entry needs enough context to match future situations, and a clear statement of what went wrong.&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;"action"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="s2"&gt;"restart service payments-api"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="w"&gt;
  &lt;/span&gt;&lt;span class="nl"&gt;"context"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="s2"&gt;"high latency, 5xx errors, during traffic peak"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="w"&gt;
  &lt;/span&gt;&lt;span class="nl"&gt;"outcome"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="s2"&gt;"dropped in-flight transactions, 40 min recovery"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="w"&gt;
  &lt;/span&gt;&lt;span class="nl"&gt;"severity"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="s2"&gt;"block"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="w"&gt;
  &lt;/span&gt;&lt;span class="nl"&gt;"source"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="s2"&gt;"postmortem 2026-09-14"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="w"&gt;
  &lt;/span&gt;&lt;span class="nl"&gt;"expires"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="s2"&gt;"2027-03-14"&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;Two fields matter most. &lt;code&gt;severity&lt;/code&gt; tells the agent whether this is a hard block (never do it without a human) or a soft warning (do it, but mention the risk). &lt;code&gt;expires&lt;/code&gt; stops old lessons from outliving the systems they were about.&lt;/p&gt;

&lt;h2&gt;
  
  
  How the agent uses it
&lt;/h2&gt;

&lt;p&gt;The loop is simple. Before the agent runs a tool or proposes a fix, it searches the negative memory for entries similar to the planned action and the current context. Matches are injected into the prompt as constraints, not as suggestions:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;Do not perform these actions in this situation:
- restart payments-api during a traffic peak (dropped transactions, Sept 2026)
- roll back the orders schema (data loss, Aug 2026)
If one of these seems necessary, stop and ask a human.
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;For &lt;code&gt;block&lt;/code&gt; entries, do not rely on the prompt alone. Check the planned tool call in code and refuse it. Prompts are advice; code is enforcement.&lt;/p&gt;

&lt;h2&gt;
  
  
  Where the entries come from
&lt;/h2&gt;

&lt;p&gt;You do not need a research project to start. Three sources cover most of it:&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;
&lt;strong&gt;Postmortems.&lt;/strong&gt; Every incident review already lists what was tried and what made it worse. Turn those lines into entries.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Failed tool calls.&lt;/strong&gt; When the agent runs a command and the result is an error or a worse metric, log the action, the context and the result automatically.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Human corrections.&lt;/strong&gt; When an operator overrides the agent ("no, don't do that"), store the override with a short reason.&lt;/li&gt;
&lt;/ol&gt;

&lt;h2&gt;
  
  
  Pitfalls
&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;Over-blocking.&lt;/strong&gt; A failure in one environment is not a rule for all of them. Scope entries by service, environment and time.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Stale rules.&lt;/strong&gt; Systems change. Use expiry dates and review entries that keep firing.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Vague entries.&lt;/strong&gt; "Restarting is bad" is useless. "Restarting payments-api during peak drops transactions" is a rule the agent can match.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Secrets in logs.&lt;/strong&gt; Failed commands often contain credentials. Strip them before storing.&lt;/li&gt;
&lt;/ul&gt;

&lt;h2&gt;
  
  
  Start today, with free tools
&lt;/h2&gt;

&lt;p&gt;A SQLite table and a local embedding model are enough for a first version. Store entries as rows, embed &lt;code&gt;action + context&lt;/code&gt;, and run a similarity search before each tool call. If embeddings feel like too much, keyword matching on service name and action type already catches most repeats.&lt;/p&gt;

&lt;p&gt;The result is an agent that behaves less like a confident intern and more like someone who has been paged at 3 a.m. and remembers why.&lt;/p&gt;

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