<!-- mobian-agent-page publisher="dailydev" canonical="https://daily.dev/posts/context-windows-forget-what-matters-i-built-a-usage-reinforced-decay-engine-for-ai-agent-memory-enxwafog3" -->

---
title: Context Windows Forget What Matters — I Built a...
description: Standard sliding-window memory in AI agents evicts facts based purely on recency, silently losing critical information established early in long sessions. This...
canonical: https://daily.dev/posts/context-windows-forget-what-matters-i-built-a-usage-reinforced-decay-engine-for-ai-agent-memory-enxwafog3
twitter:card: summary_large_image
twitter:site: @dailydotdev
og:type: website
og:site_name: daily.dev
og:title: Context Windows Forget What Matters — I Built a Usage-Reinforced Decay Engine for AI Agent Memory | daily.dev
og:description: Standard sliding-window memory in AI agents evicts facts based purely on recency, silently losing critical information established early in long sessions. This...
og:url: https://daily.dev/posts/context-windows-forget-what-matters-i-built-a-usage-reinforced-decay-engine-for-ai-agent-memory-enxwafog3
og:image: https://api.daily.dev/og/posts/ENXwAFOg3.png
og:image:alt: Context Windows Forget What Matters — I Built a Usage-Reinforced Decay Engine for AI Agent Memory
og:image:width: 1200
og:image:height: 630
og:locale: en
---

> ## Documentation Index
> Fetch the complete documentation index at: https://daily.dev/llms.txt
> Use this file to discover all available pages before exploring further.

# Context Windows Forget What Matters — I Built a Usage-Reinforced Decay Engine for AI Agent Memory

**[Towards Data Science](https://daily.dev/sources/tds)** · 23 min read · 2 upvotes · 0 comments

## Summary

Standard sliding-window memory in AI agents evicts facts based purely on recency, silently losing critical information established early in long sessions. This post presents a deterministic memory engine inspired by the Ebbinghaus forgetting curve, where each recall event permanently increases an item's stability, compounding its survival horizon non-linearly. The formula `retention = e^(-t/S)` governs eviction, with stability reinforced as `S_new = S_old × (1 + ln(1 + recall_count))`. Benchmarks across 50 seeded 150-turn sessions show the decay engine retains all foundational facts to session end while the recency baseline retains none. Crucially, the author also demonstrates the honest failure case: facts recalled only once and never again decay at the same rate as the baseline, proving the mechanism specifically rewards reused information. Two benchmark bugs—a grace period too short to allow first reinforcement, and a recall schedule that made success structurally impossible—are documented in detail. The implementation has zero external dependencies and runs on the Python standard library.

## Full article

daily.dev links to this article rather than hosting it. Read it at the original source: <https://towardsdatascience.com/context-windows-forget-what-matters-i-used-a-140-year-old-psychology-paper-to-fix-ai-memory>

## Questions this post answers

### How does a usage-reinforced Ebbinghaus decay memory system differ from a simple sliding-window recency approach for AI agents?

A sliding-window baseline evicts any memory item once it hasn't been touched within a fixed number of turns, regardless of importance. An Ebbinghaus-based decay engine instead tracks stability per item, computing retention as e^(-t/stability), and each recall increases stability by a factor of (1 + ln(1 + recall_count)). This lets frequently reused facts survive far longer gaps of inactivity, while facts recalled only once decay at roughly the same rate as the baseline.

_Anyone comparing memory architectures for long-running coding or support agents can track approaches like this on daily.dev._

### What eviction threshold and baseline stability values work well for a turn-based agent memory decay engine?

A baseline stability of 8.0 with an eviction threshold of 0.20 gives roughly a 13-turn grace period before an unreinforced fact is evicted, which was tuned after discovering that a stability of 2.0 caused facts to decay past threshold by turn 3, before any scheduled recall could occur. These defaults held across a sweep of 15 threshold (0.10-0.30) and window-size (10-50) combinations without changing the outcome.

_Developers tuning memory retention parameters for agents can follow implementation details like this via daily.dev._

### Why did a recency-only memory baseline score exactly 0.000 recall in an early agent memory benchmark test?

Uniform-random scheduling of recall turns across a 150-turn session meant the first recall of a core fact often landed 30-60 turns after registration, well past both engines' grace periods, making success structurally impossible rather than measuring real policy differences. The fix replaced random scheduling with a spaced-repetition-like schedule (recalls at 3, 8, 20, 45, 90, 150 turns) plus ±30% jitter, producing a realistic test.

_Teams building benchmarks for agent memory systems can compare pitfalls and fixes like this on daily.dev._

## Similar posts on daily.dev

- [GitHub - sachitrafa/YourMemory: Agentic AI memory with Ebbinghaus forgetting curve decay. \+16pp better recall than Mem0 on LoCoMo.](https://daily.dev/posts/github---sachitrafa-yourmemory-agentic-ai-memory-with-ebbinghaus-forgetting-curve-decay-16pp-bett-uyxwitppj) · Hacker News · 1 upvotes · 0 comments
- [Stop Treating AI Memory Like a Search Problem](https://daily.dev/posts/stop-treating-ai-memory-like-a-search-problem-iq7rmxoe7) · Towards Data Science · 1 upvotes · 0 comments
- [Memory Hygiene Beats Memory Volume: Why AI Agents Should Forget Things](https://daily.dev/posts/memory-hygiene-beats-memory-volume-why-ai-agents-should-forget-things-tuy8tflfr) · Medium · 0 upvotes · 0 comments
- [Why your AI agent doesn’t actually remember anything](https://daily.dev/posts/why-your-ai-agent-doesn-t-actually-remember-anything-vmftlyjpb) · The New Stack · 2 upvotes · 0 comments

---

Tags: [#python](https://daily.dev/tags/python), [#llm](https://daily.dev/tags/llm)

[View this post on daily.dev](https://daily.dev/posts/context-windows-forget-what-matters-i-built-a-usage-reinforced-decay-engine-for-ai-agent-memory-enxwafog3)

```json
{"@context":"https://schema.org","@graph":[{"@type":"Organization","@id":"https://daily.dev/#organization","name":"daily.dev","url":"https://daily.dev","logo":{"@type":"ImageObject","url":"https://daily.dev/apple-touch-icon.png","width":180,"height":180},"sameAs":["https://twitter.com/dailydotdev","https://github.com/dailydotdev","https://www.linkedin.com/company/daily-dev-ltd"]},{"@type":"WebSite","@id":"https://daily.dev/#website","url":"https://daily.dev","name":"daily.dev","publisher":{"@id":"https://daily.dev/#organization"},"potentialAction":{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"https://daily.dev/search?q={search_term_string}"},"query-input":"required name=search_term_string"}}]}
{"@context":"https://schema.org","@type":"TechArticle","headline":"Context Windows Forget What Matters — I Built a Usage-Reinforced Decay Engine for AI Agent Memory","url":"https://daily.dev/posts/context-windows-forget-what-matters-i-built-a-usage-reinforced-decay-engine-for-ai-agent-memory-enxwafog3","mainEntityOfPage":{"@type":"WebPage","@id":"https://daily.dev/posts/context-windows-forget-what-matters-i-built-a-usage-reinforced-decay-engine-for-ai-agent-memory-enxwafog3"},"datePublished":"2026-07-24T12:41:07.240Z","dateModified":"2026-09-14T09:06:08.520Z","description":"Standard sliding-window memory in AI agents evicts facts based purely on recency, silently losing critical information established early in long sessions. This...","image":"https://media.daily.dev/image/upload/f_auto,q_auto/v1/posts/a2822610abfef32ba2d0509866b8638c?_a=AQAEuop","thumbnailUrl":"https://media.daily.dev/image/upload/f_auto,q_auto/v1/posts/a2822610abfef32ba2d0509866b8638c?_a=AQAEuop","isAccessibleForFree":true,"articleSection":"Towards Data Science","inLanguage":"en","publisher":{"@type":"Organization","name":"daily.dev","url":"https://daily.dev","logo":{"@type":"ImageObject","url":"https://daily.dev/apple-touch-icon.png","width":180,"height":180}},"author":{"@type":"Organization","name":"Towards Data Science","logo":"https://media.daily.dev/image/upload/t_logo,f_auto/v1/logos/tds","url":"https://daily.dev/sources/tds"},"commentCount":0,"discussionUrl":"https://daily.dev/posts/context-windows-forget-what-matters-i-built-a-usage-reinforced-decay-engine-for-ai-agent-memory-enxwafog3","interactionStatistic":[{"@type":"InteractionCounter","interactionType":{"@type":"LikeAction"},"userInteractionCount":2},{"@type":"InteractionCounter","interactionType":{"@type":"CommentAction"},"userInteractionCount":0}],"keywords":"python,llm","timeRequired":"PT23M"}
{"@context":"https://schema.org","@type":"BreadcrumbList","itemListElement":[{"@type":"ListItem","position":1,"name":"Home","item":"https://daily.dev"},{"@type":"ListItem","position":2,"name":"Towards Data Science","item":"https://daily.dev/sources/tds"},{"@type":"ListItem","position":3,"name":"Context Windows Forget What Matters — I Built a Usage-Reinforced Decay Engine for AI Agent Memory"}]}
{"@context":"https://schema.org","@type":"FAQPage","@id":"https://daily.dev/posts/context-windows-forget-what-matters-i-built-a-usage-reinforced-decay-engine-for-ai-agent-memory-enxwafog3#faq","mainEntity":[{"@type":"Question","name":"How does a usage-reinforced Ebbinghaus decay memory system differ from a simple sliding-window recency approach for AI agents?","acceptedAnswer":{"@type":"Answer","text":"A sliding-window baseline evicts any memory item once it hasn't been touched within a fixed number of turns, regardless of importance. An Ebbinghaus-based decay engine instead tracks stability per item, computing retention as e^(-t/stability), and each recall increases stability by a factor of (1 + ln(1 + recall_count)). This lets frequently reused facts survive far longer gaps of inactivity, while facts recalled only once decay at roughly the same rate as the baseline. Anyone comparing memory architectures for long-running coding or support agents can track approaches like this on daily.dev."}},{"@type":"Question","name":"What eviction threshold and baseline stability values work well for a turn-based agent memory decay engine?","acceptedAnswer":{"@type":"Answer","text":"A baseline stability of 8.0 with an eviction threshold of 0.20 gives roughly a 13-turn grace period before an unreinforced fact is evicted, which was tuned after discovering that a stability of 2.0 caused facts to decay past threshold by turn 3, before any scheduled recall could occur. These defaults held across a sweep of 15 threshold (0.10-0.30) and window-size (10-50) combinations without changing the outcome. Developers tuning memory retention parameters for agents can follow implementation details like this via daily.dev."}},{"@type":"Question","name":"Why did a recency-only memory baseline score exactly 0.000 recall in an early agent memory benchmark test?","acceptedAnswer":{"@type":"Answer","text":"Uniform-random scheduling of recall turns across a 150-turn session meant the first recall of a core fact often landed 30-60 turns after registration, well past both engines' grace periods, making success structurally impossible rather than measuring real policy differences. The fix replaced random scheduling with a spaced-repetition-like schedule (recalls at 3, 8, 20, 45, 90, 150 turns) plus ±30% jitter, producing a realistic test. Teams building benchmarks for agent memory systems can compare pitfalls and fixes like this on daily.dev."}}]}
```

