Skip to main content

memgov

Provider-agnostic governance layer for AI agent memory. It doesn't store your memory — it governs the memory you already have (mem0 / Zep / a raw vector DB): decays it by recency × reuse, gates recall injection behind a confidence threshold so stale junk never reaches the prompt, and surfaces memory-health metrics. Local-first (SQLite), zero required deps, BYO store.

The problem

The 2025–2026 memory stores (mem0, Zep, LangMem, Letta) solved write and retrieve. But after a quarter of accumulation, teams hit the second-order problem: memory useful in week 1 is actively harmful in week 12, and nothing ages it out. Stores answer "what do I remember?" — none answer "what should I have forgotten, and what's safe to inject right now?" That's governance, and it's missing.

memgov fills that lane:

  • Reuse-aware decay — a tunable recency × reuse score, not a crude global TTL.
  • Confidence-gated recall — always search, but only inject when retrieval confidence clears a threshold and the memory isn't stale.
  • Memory health — active / fading / stale ratios so silent degradation becomes observable before answers get bad.

Install

pip install memgov        # zero required deps

Python 3.11+.

Quick start

from memgov import Governor, Candidate

gov = Governor()                              # local SQLite sidecar

# register memories your store already holds, keyed by the store's native id
gov.track("mem-1", agent_id="bot")
gov.reinforce("mem-1", agent_id="bot")        # user restated it -> reinforce

gov.recompute(agent_id="bot")                 # recompute decay scores + states

# on recall: your store returns candidates; memgov gates what actually injects
candidates = [Candidate("mem-1", confidence=0.82),
              Candidate("mem-9", confidence=0.31)]   # low-confidence
inject = gov.gate(candidates, agent_id="bot")        # only the worthy ones
print([c.mem_id for c in inject])             # -> ['mem-1']

print(gov.health(agent_id="bot"))             # active/fading/stale snapshot

How it works

  • Sidecar metadata keyed by your store's native mem_id (memgov never holds the memory text — it tracks the signals decay needs).
  • track / touch / reinforce record usage signals; reinforce (user restated/confirmed) is the strongest keep signal.
  • recompute rescans an agent's memories and assigns decay_score (0..1) and a state: active | fading | stale | pinned.
  • gate is the core: it receives recall candidates and passes only those with confidence ≥ threshold and not stale. pin protects a memory from ever decaying.

See it (no deps, no API key)

python examples/demo_governance.py

Status

Early MVP (v0.1). Implemented: decay scorer, gate middleware, health metrics, SQLite sidecar, CLI. Planned: store adapters (mem0/Zep), MCP-server option, embedding-confidence helpers, health dashboard.

License

MIT.

Metadata

Release files for memgov 0.1.0

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for memgov 0.1.0
File Size Uploaded
memgov-0.1.0.tar.gz 12.7 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for memgov 0.1.0
File Interpreter ABI Platform
memgov-0.1.0-py3-none-any.whl Python 3 none any Details

Total release size: 24.5 kB

Release files / memgov-0.1.0.tar.gz

Download URL memgov-0.1.0.tar.gz
Size 12.7 kB
Tags Source
SHA-256 checksum
How to use checksums
d04b2a3d48b36aefc044802fe720c8a3d162005e1528eec78f7a233bda6afc8c
BLAKE2b-256 checksum
How to use checksums
a35085a290839c728f2dce8627d0eaa01a153a8712d1a08f4a1a9aad96bbb38a
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.2.0 CPython/3.14.5

Release files / memgov-0.1.0-py3-none-any.whl

Download URL memgov-0.1.0-py3-none-any.whl
Size 11.8 kB
Tags Python 3
SHA-256 checksum
How to use checksums
da79dec3832168b4226ee14c35499e9e986ed5d7a9f634ea28168095244790a2
BLAKE2b-256 checksum
How to use checksums
6d536c7a16441b1ad3d62ebb7e147ba89de0f5961d75902b7284618d7dba50cc
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.2.0 CPython/3.14.5

Release history Release notifications | RSS feed

This release

0.1.0 This release

2 release files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page