Spectre Mnemonic: Memory for Agents That Actually Forgets Correctly

Spectre Mnemonic: Memory for Agents That Actually Forgets Correctly

By Yuriy Zhar 7 min read
The third article in the Spectre series introduces Spectre Mnemonic, an Elixir-first memory layer for agents with scoped recall, lifecycle governance, observations, mental models, and forgetting.

This is the third article in the Spectre series. First came Spectre Kinetic, where the model expresses intent and Elixir decides what reality accepts. Then came Spectre Lens, where agents get browser perception without being forced to chew raw DOM like a cursed goat. Now we arrive at memory, which is where most agent systems put on a lab coat, create a vector table, and start lying to themselves.

Vector Search Is Not Memory, It Is Search With Better Shoes

Everyone says agents need memory. Then they create embeddings, store chunks, add a cosine similarity query, and suddenly we are supposed to believe the machine has a childhood. Cute. Wrong, but cute.

Vector search remembers what sounds similar. Real memory remembers what still matters. That difference is not philosophical decoration. It is the difference between an agent recalling the current payment policy and confidently resurrecting a decision from six weeks ago that was already replaced, contradicted, buried, and emotionally processed by the team.

Memory has lifecycle. Some things are temporary. Some become important. Some go stale. Some are contradicted by newer facts. Some must be forgotten because privacy exists and because production systems are not allowed to become creepy little hoarders with logs.

Spectre Mnemonic exists for that uncomfortable middle space. It is not your application database. It is not a magic brain. It is a memory layer beside your application, built for agents and live systems that need working memory, durable recall, scoped context, observations, mental models, governance, and the sacred right to forget.

Yes, The Name Is A Johnny Mnemonic Joke, Behave

Of course the name is Mnemonic. Yes, like Johnny Mnemonic, the cyberpunk movie where a man carries important data in his head and everyone treats that as a totally reasonable infrastructure decision. Honestly, still more sane than half the agent memory architectures being shipped today.

The joke works because agents really do walk around with overloaded heads. Context windows stuffed with chat history. Prompt fragments. Tool results. Random summaries. Old facts. User preferences. Half-remembered goals. Somewhere in there is the one useful thing the model needs, sitting between “the user likes concise answers” and “here is a full HTML dump from a pricing page in 2024.”

Memory is not storage. Memory is selection under pressure.

Spectre Mnemonic treats memory as a living system. It records moments. It recalls context. It promotes useful knowledge. It marks stale and contradicted facts. It supports scoped recall so one tenant, project, user, or agent does not accidentally inherit another one’s emotional baggage. This is not pessimism. This is production with better hygiene.

The Basic Ritual: Remember, Recall, Search, Consolidate

The nice thing is that the public shape stays boring. Boring is holy. You remember something. You recall related context. You search active and durable memory. You consolidate what deserves to survive longer than the current hot working set.

{:ok, memory} =
  SpectreMnemonic.remember("Alice email is alice@example.com",
    stream: :chat,
    kind: :personal_fact,
    persist?: true
  )

{:ok, packet} = SpectreMnemonic.recall("Alice email")
{:ok, results} = SpectreMnemonic.search("Alice email")
{:ok, durable} = SpectreMnemonic.consolidate()

This is the correct level of ceremony. The agent does not need to decide which storage family should receive a fact. It should say what happened. Your runtime records it with stream, kind, scope, metadata, persistence rules, and whatever policy your application cares about.

Use remember when you want normal intake: text, maps, parsed documents, chat, tasks, research notes, code notes, and tool events. Use recall when the agent needs active context. Use search when you want active recall plus durable persisted memory. Use consolidate when the system has seen enough to promote important moments into more durable knowledge.

{:ok, packet} =
  SpectreMnemonic.remember("TODO: implement durable graph search",
    title: "Planner note",
    stream: :planning,
    task_id: "alpha",
    scope: {:project, "alpha"},
    metadata: %{source: :agent},
    persist?: true
  )

packet.root
packet.chunks
packet.summaries
packet.categories
packet.associations

That packet matters. It is not just “stored text.” Intake can produce chunks, summaries, categories, associations, and graph shape. The memory becomes something the runtime can inspect, not a pile of embeddings wearing a fake mustache.

Recall Should Have Boundaries, Budgets, And A Sense Of Time

An agent without scoped memory is a lawsuit doing yoga. It sounds flexible until one customer’s context leaks into another customer’s answer. Spectre Mnemonic supports scope because memory belongs somewhere. A project. A tenant. A user. A session. A little supervised island where facts can live without wandering into the wrong neighborhood.

{:ok, packet} =
  SpectreMnemonic.recall("how is alpha going?",
    scope: {:project, "alpha"},
    max_tokens: 2_000,
    budget: :mid
  )

packet.moments
packet.observations
packet.mental_models
packet.active_status
packet.associations
packet.knowledge

This is where the library starts feeling less like storage and more like memory. Recall returns a packet, not a random list of similar chunks. The agent can receive moments, observations, mental models, active status, associations, and compact knowledge. In other words, it gets context shaped for thinking, not a haystack with confidence scores.

Time also matters. When something happened is not always when the system learned it. When a fact became valid is not always when it was last verified. If that sounds fussy, congratulations, you have never watched an agent answer with stale business rules because an old note had great semantic vibes.

SpectreMnemonic.remember("Payment retry policy is stable",
  scope: {:tenant, "acme"},
  mission: :code_agent,
  occurred_at: ~U[2026-05-01 12:00:00Z],
  valid_from: ~U[2026-05-01 00:00:00Z],
  persist?: true
)

SpectreMnemonic.recall("payment retry",
  scope: {:tenant, "acme"},
  valid_at: ~U[2026-05-30 00:00:00Z]
)

That is the sort of boring detail that makes an agent useful after the demo. Memory without validity is just nostalgia with an API.

Contradictions Are Not Bugs, They Are Reality Arriving Late

Real systems change. Alice’s email changes. A deadline moves. A task goes from blocked to done. A policy gets replaced. If your memory layer only appends facts and retrieves the most similar one, your agent becomes that coworker who remembers every old decision except the current one.

Spectre Mnemonic has governance states: candidate, short term, promoted, pinned, stale, contradicted, and forgotten. That is a much better mental model than “everything is a document and all documents are equally alive.” No, they are not. Some memories are fresh. Some are dead. Some are undead and should not be invited to planning meetings.

{:ok, %{moment: old}} =
  SpectreMnemonic.signal("Alice email is old@example.com",
    persist?: true
  )

{:ok, %{moment: new}} =
  SpectreMnemonic.signal("Alice email is new@example.com",
    persist?: true
  )

SpectreMnemonic.Governance.state_for(old.id)
#=> :contradicted

SpectreMnemonic.Governance.state_for(new.id)
#=> :promoted

This is the part that saves you from semantic archaeology. The older fact is not deleted from history, because provenance matters, but it is no longer treated as the current truth. The newer fact gets promoted. The runtime knows the difference. The model gets cleaner context. Everybody becomes slightly less haunted.

Forgetting also matters. Spectre Mnemonic can forget active memories and write tombstones. This is not dramatic. This is basic hygiene. A memory system that cannot forget is not wise. It is just a surveillance cabinet with better branding.

Observations, Mental Models, And Reflection Packets

Raw moments are useful, but agents also need higher-level understanding. Not fake consciousness. Please relax. I mean boring, inspectable, evidence-grounded observations and curated mental models. The kind of thing your application can store, rank, verify, and cite back into a prompt without pretending the model had a spiritual awakening.

{:ok, observations} =
  SpectreMnemonic.consolidate_observations(
    scope: {:project, "alpha"}
  )

{:ok, matches} =
  SpectreMnemonic.search_observations("payment retry",
    scope: {:project, "alpha"}
  )

{:ok, model} =
  SpectreMnemonic.put_mental_model(%{
    title: "Payment Retry Policy",
    query: "payment retry",
    answer: "Use bounded retries with idempotency keys.",
    scope: {:project, "alpha"},
    source_ids: ["mom_123"]
  })

Mental models are especially useful for recurring questions. When the same question keeps coming back, the system should not rebuild the answer from raw fragments every time like a goldfish with a GPU budget. Store the stable answer. Keep the source ids. Let recall and search bring it back when needed.

{:ok, packet} =
  SpectreMnemonic.reflect("What is the payment retry policy?",
    scope: {:project, "alpha"},
    max_tokens: 4_096
  )

packet.mental_models
packet.observations
packet.raw_memories
packet.citations
packet.response

Reflect is the grown-up packet. Mental models first. Ranked observations second. Raw evidence after that. This is how you stop stuffing every old event into the prompt and start giving the model a clean briefing. The agent does not need infinite memory. It needs the right memory at the right time with enough evidence to avoid becoming a confident little fiction machine.

The Spectre Pattern Is Becoming Clear

Kinetic makes intent inspectable. Lens makes pages legible. Mnemonic makes memory governed. None of them try to become the whole agent. That is the point. A good agent system is not one giant abstraction screaming “autonomy” while hiding all the sharp edges under a rug.

Spectre Mnemonic gives agents a memory layer that understands heat, durability, scope, facts, contradictions, observations, mental models, secrets, action recipes, and compact knowledge. It can work locally and deterministically without embeddings, then use embeddings when you actually want them. It keeps hot working memory in ETS, durable records in append-only storage, and recall packets small enough that the context window does not need therapy.

The model should not remember everything. It should ask for context. The runtime should decide what matters. The memory layer should carry evidence, lifecycle, and boundaries. That is the sacred split again: imagination on one side, governed recall on the other.

An agent is not intelligent because it remembers. It becomes useful when it remembers with discipline.

Send via.chat
Recommended Tool

Send via.chat

Receive form leads, send login codes, and route important alerts through WhatsApp or Telegram.

Share this article:
Yuriy Zhar

Yuriy Zhar

github.com

Passionate web developer. Love Elixir/Erlang, Go, TypeScript, Svelte. Interested in ML, LLM, astronomy, philosophy. Enjoy traveling and napping.

Get in Touch

Have a question or want to work together? Drop a message below.

Book a Call

Stay updated

Subscribe to our newsletter and get the latest articles delivered to your inbox.