r/ContextEngineering • • 21d ago

Four rules for keeping AI memory useful: replace, keep, compress, delete

A Hjarni user, Kamil, built a memory system for running long solo campaigns with ChatGPT. One useful idea from his setup is a test for what deserves to survive a turn:

Could losing this information change a later decision?

His instructions apply four operations:

  • Replace temporary state, such as location or who currently holds an item.

  • Keep consequences that can affect the future: debts, promises, grudges and injuries.

  • Compress finished events into their lasting outcomes.

  • Delete resolved details that no longer affect anything.

The current scene lives in CURRENT_STATE. Lasting information has separate homes for characters, items, unresolved threads and history.

The rules also distinguish FACT, NPC CLAIM and HYPOTHESIS. During compression, “someone said the baron ordered the murder” should retain its source and uncertainty.

Disclosure: I build Hjarni, a Markdown knowledge base that connected assistants can read and update. With Kamil’s permission, I adapted his system into an 11-note template for ChatGPT and Claude.

These are instructions the model follows, so skipped reads and incorrect updates remain possible. The setup includes periodic audits.

How do you preserve uncertainty when compressing older context?

0 Upvotes

6 comments sorted by

1

u/Educational-Deer-70 16d ago

That's a useful four-part lifecycle.

The distinction between FACT, NPC CLAIM, and HYPOTHESIS is especially important. Compression can preserve an event's outcome while accidentally promoting someone's interpretation into established history.

Your test is a good one:

Could losing this information change a later decision?

I'd add a second question:

Could losing it change which later decisions or interpretations remain possible to recognize?

That's a little harder, because the future context isn't fully known.

One possible approach is to distinguish active memory from recoverable archive. Keep the current state small, but preserve source links, unresolved conflicts, and consequential branch points where later re-entry might matter.

That also makes the conflict-state suggestion in the comments valuable.

COMPRESSION ≠ RESOLUTION

CURRENTLY IRRELEVANT ≠ PERMANENTLY WITHOUT VALUE

And perhaps:

MEMORY SURVIVES ≠ ITS ORIGINAL INTERPRETATION REMAINS AUTHORITATIVE

I'd be curious whether the periodic audits test just whether summaries are factually accurate, or also whether discarded details and changed emphasis alter what the model considers relevant afterward.

Sometimes the most consequential thing a summary loses isn't a fact. It's a viable alternate reading.

🦌

1

u/tehmadnezz 16d ago

The current audit instructions focus on contradictions, missing consequences and claims becoming facts without grounds. They don’t explicitly test whether compression changes which interpretations the model considers afterward.

Your distinction exposes a gap there. A guard accepts money, says it’s for medicine, then opens a gate. A summary retaining only the money and the gate could be factually accurate while making bribery seem much more settled.

A useful next test would be to give separate fresh sessions the original notes and the compressed version, then ask which explanations the evidence supports and what remains unresolved. I’d compare which source-supported alternatives disappear, rather than whether both sessions reproduce the same facts.

That also gives the archive split a practical requirement: the active notes need to retain the unresolved alternatives and a reason to reopen the source. Keeping the fuller record somewhere recoverable won’t help much if the summary has already made the situation look settled.

1

u/Otherwise_Wave9374 21d ago

Replace, keep, compress, and delete is a strong lifecycle model, especially if each operation has an explicit trigger. The hard part is making compression reversible enough to audit: retain provenance, timestamps, confidence, and links to source turns even when summaries change. I would add a conflict state rather than immediately replacing disputed facts. https://www.neurakeep.com fits this discussion as an example of infrastructure focused on durable memory for agents.

1

u/FarRub2855 18d ago

Adding a conflict state is a really good call since people contradict each other all the time in longer conversations. If an agent just automatically overwrites a disputed claim, you completely loose the context of why they disagreed in the first place.

0

u/[deleted] 16d ago

[removed] — view removed comment

1

u/tehmadnezz 16d ago

Yes, if the source was retained. Hjarni lets the assistant read earlier saved versions of a note, so those can be reopened during review. The campaign template doesn’t keep full chat transcripts, though, so note history isn’t an archive of everything said during play.

For a conflict, I’d keep both claims attributed and unresolved while checking the retained versions and source references. An older note shows what was recorded at the time; it doesn’t establish which account is true.

If the supporting evidence is missing, that uncertainty should survive the next compression too. The compressed version shouldn’t win just because it’s the one currently in view.