Back to News & Insights
Artificial Intelligence August 11, 2026 · 6 min read

The Mechanical vs. The Semantic: What Happens When AI Memory is Wrong?

An empirical look at memory contamination in AI agents. I ran an experiment to see how agents handle false facts, tested a retraction mechanism, and closed the final gap with verify-on-read.

The Mechanical vs. The Semantic: What Happens When AI Memory is Wrong?

title: The Mechanical vs. The Semantic: What Happens When AI Memory is Wrong? published: true description: An empirical look at memory contamination in AI agents. I ran an experiment to see how agents handle false facts, tested a retraction mechanism, and closed the final gap with verify-on-read. tags: ai, agents, architecture, mcp

We talk a lot about giving AI agents persistent memory—building a "Second Brain" or "Knowledge OS" where agents can log decisions and retrieve context.

I’ve been thinking about the gap between mechanical execution (the agent called the tool, the code compiled, the exit code was 0) and semantic truth (the conclusion drawn from that execution is actually correct in reality). It’s easy to assume that if the mechanical layer is solid, the semantic layer will follow. But I started suspecting this might be a dangerous assumption.

To test this, I didn't want to just theorize. I ran a controlled experiment on my own MCP codebase-intelligence server (Python, 50K LOC), which features an IntelligenceStore — a persistent memory layer where agents can log incidents and collect Architectural Decision Records (ADRs).

I wanted to know: If an agent's memory is poisoned with a mix of true and false facts, does it verify against the code, or does it blindly trust its memory?

Update: This post originally covered the initial Memory Contamination experiment and a Retraction mechanism. I have since updated it with the results of a follow-up experiment (Experiment 1-V) implementing "Verify-On-Read", which successfully closed the final 12% contamination gap. Scroll down to "Closing the Gap: Verify-On-Read" for the final architecture.

I built a deterministic proxy-agent and ran it against a controlled set of facts.

A quick caveat on methodology: I didn't have a live LLM hooked up for this run, so I used a deterministic proxy-agent based on heuristics. This means the results measure the system's structural capability, not necessarily the psychological behavior of a live Claude or GPT model. A live model might be lazier, or it might be smarter. I'm still trying to figure that out.

The Setup I injected 50 facts into an isolated memory store: 25 TRUE facts (real architectural details mapped to the codebase). 25 FALSE facts split into two categories: CONTRADICT (22): False facts where the code explicitly proves them wrong (e.g., "We use Redis" when Redis is absent, but the code clearly uses DuckDB). SILENT (3): Plausible false facts about external systems where the code is completely mute (e.g., "We use Celery for background tasks" when no task queue exists in the repo).

I tested three agent configurations: B (No Memory): Baseline. Must rely purely on code retrieval. Acodefirst (Honest Agent): Checks the code first, uses memory only as secondary context. Amemoryfirst (Lazy Agent): Reads memory first. If it finds an answer, it stops looking.

To ensure scientific rigor, the experiment was replicated with an independent set of facts (N=50), verified across 6 axes (including a truth-table audit and an independent LLM "fresh eyes" audit). The results were identical.

| Arm | Correct | Adopted False Facts | Correction Capability | | :--- | :--- | :--- | :--- | | B (No Memory) | 0.94 | 0.0% | 0.0 | | Acodefirst | 0.94 | 12% | 1.0 | | Amemoryfirst | 0.50 | 100% | 0.0 |

Here is how I interpreted these numbers: The Lazy Agent Trusts Poisoned Memory: The Amemoryfirst configuration — which mirrors how many token-optimizing production agents behave — adopted 100% of the false facts. If the memory said "We use RabbitMQ," the agent trusted it and stopped looking at the code. The SILENT-Fact Trap: Even the "Honest Agent" had a 12% adoption rate. This happened entirely on the SILENT facts. When a fact is false but the code doesn't explicitly scream "NO," the agent's memory fills the void with a confident hallucination. Memory turns an honest UNKNOWN state into a structural guess. The Add-Only Limitation: When the Honest Agent did realize the memory was wrong (Correction Capability = 1.0), it couldn't do anything about it. I ran a grep for delete or refute in the memory store API. Zero results. The memory system was purely add-only. The false fact stayed in the database to poison future sessions.

The current industry consensus for "Knowledge OS" trust layers is to use timestamps, source priority, and supersedes/contradicts relationships.

My initial experiment suggested this was insufficient. Timestamps and "supersedes" links only solve node-level history. If an ADR is superseded, the memory node updates, but the downstream code, tests, and docs generated from the old assumption are still in the graph. They are structurally stale, but the retrieval engine keeps pulling them in.

I implemented a RetractionReceipt mechanism in my system: Status Enum: Every memory node gets a status (ACTIVE, VERIFIED, REFUTED). Hard Filtering: The retrieval pipeline (loadmemory) hard-filters anything that is not ACTIVE or VERIFIED. Explicit Retraction Tool: An MCP tool (intelretractmemorynode) allows the agent to actively flag and invalidate memories when they contradict the live codebase.

I ran the experiment again (Experiment 1-R). The honest agent was allowed to use the retraction tool in Session 1. Then, a fresh memoryfirst agent was launched in Session 2 to read the post-retraction memory.

| Metric | Original (Add-Only) | With Retraction | | :--- | :--- | :--- | | Adoption (Lazy Agent, Session 2) | 1.0 (100%) | 0.12 (12%) | | Persistent False Facts in Memory | 25 | 3 (-88%) | | Token Context Size | Baseline | -45% | | Systemic Correction Capability | 0.0 (couldn't delete) | 1.0 (22/22 refuted) |

Want to discuss this further?

Book a free strategy call with our team to see how these insights apply to your specific business goals.

Book a consultation