explaingit

kresnapandu/memwatch

18PythonAudience · developerComplexity · 2/5LicenseSetup · easy

TLDR

memwatch is a Python library that tracks how stale each fact in an AI agent's memory has become, using decay curves and contradiction detection to flag or discard outdated information like old job titles or previous addresses before the agent repeats them.

Mindmap

mindmap
  root((repo))
    What It Does
      Track memory freshness
      Flag stale facts
      Detect contradictions
    Three Approaches
      Temporal decay scores
      Contradiction detection
      Category time-to-live
    Nine Categories
      Employment location contact
      Preference relationship skill
      Belief fact general
    Integrations
      mem0 adapter
      LangChain adapter
      SQLite overlay adapter
    Setup
      pip install memwatch
      Optional sentence-transformers
Click or tap to explore — scroll the page freely

Code map

Detail Auto

An interactive map of this repo's files and how they connect — its source is parsed live in your browser. Click Visualize to build it.

filefunction / class

Things people build with this

USE CASE 1

Add staleness tracking to a mem0 or LangChain agent so it stops repeating outdated facts after the user mentions a change like switching jobs.

USE CASE 2

Use the SQLite adapter to overlay memwatch onto an existing agent memory database and add decay scores without changing the schema.

USE CASE 3

Run a freshness report on all stored agent memories to see which facts are close to expiry and review them before the agent uses them again.

USE CASE 4

Configure per-category half-lives so employment facts expire within weeks while objective facts stay valid for months.

Tech stack

Python

Getting it running

Difficulty · easy Time to first run · 5min

Install sentence-transformers for better contradiction detection, the standard-library-only build still works without it.

Use, copy, modify, and distribute freely for any purpose, including commercial use, as long as you keep the original copyright notice.

In plain English

memwatch is a Python library that helps AI agents forget things at the right time. Most agent memory systems store facts indefinitely, which means an agent might keep saying "you work at Google" months after someone changed jobs. memwatch addresses this by tracking how fresh each stored fact is and flagging or discarding it once it becomes unreliable. The library uses three complementary approaches. The first is temporal decay: each fact gets a freshness score that falls over time using a formula inspired by the Ebbinghaus forgetting curve. Different categories of facts decay at different rates, so employment data (which changes often) goes stale faster than objective facts (which rarely change). The second approach is contradiction detection, which scans new user input for signals that an old fact no longer holds, such as a sentence like "I just moved to a new city." The third is category-aware time-to-live settings, with nine predefined categories (employment, location, contact, preference, relationship, skill, belief, fact, general) that each have their own configurable half-life. Developers interact with memwatch through a simple Python API or a command-line tool. The core workflow is to add facts with a category label, call check() whenever new user input arrives, and then review any suggested updates. You can also run a report to see all stored memories along with their current freshness scores and estimated days remaining. An optional dependency on sentence-transformer embeddings improves contradiction detection, leaving it out gives a pure standard-library build. The library includes adapters for mem0, LangChain, and existing SQLite databases. These adapters let teams add staleness detection to an agent memory system without rewriting their storage layer. The SQLite adapter in particular overlays memwatch on an existing database and does not require any schema changes. memwatch is at an early stage: benchmarks are listed as coming soon and the repository was created in June 2026. It is available on PyPI, published under the MIT license, and written entirely in Python. The README does not document a server component or hosted service, so all processing runs locally.

Copy-paste prompts

Prompt 1
I use memwatch with a LangChain agent. Show me how to store a new memory fact with an employment category and call check() when the user says they just changed jobs.
Prompt 2
How do I configure the memwatch half-life for the location category so location facts expire after 30 days instead of the default setting?
Prompt 3
Using the memwatch Python API, generate a freshness report showing all stored memories with their current decay scores and estimated days remaining.
Prompt 4
Walk me through adding the memwatch SQLite adapter to an existing agent that already stores memories in a local SQLite file, without migrating any data.
Prompt 5
Can I use memwatch without the sentence-transformers dependency? What do I lose in contradiction detection and what still works with the standard library?
Open on GitHub → Explain another repo

← kresnapandu on gitmyhub — every repo by this author, as a profile.

Verify against the repo before relying on details.