SleepSweet
Enables AI agents to audit and clean their memory files by scanning for duplicates, broken links, stale facts, and conflicts, with non-destructive, reversible fixes and a full audit trail. It also lets the calling agent serve as the conflict judge through MCP tools.
README
SleepSweet — memory hygiene and audit for AI agents
Agents have a brain — we give it sleep.
SleepSweet is an open-source memory hygiene and audit layer for AI agents: an offline engine plus local CLI and MCP server that deduplicates, resolves conflicts, flags stale facts, finds broken links and dead paths, and quarantines suspicious entries in the memory your agent already keeps — CLAUDE.md, AGENTS.md, ~/.claude auto-memory, Cursor rules, and GitHub Copilot instructions. It is not a memory store and it does not do retrieval.
Cleanup is non-destructive: history is marked, never deleted. Every decision is journaled and versioned, which yields a complete audit trail of your agent's knowledge over time — what the agent knew at date X, and who changed it, when, and why.
Quick start
pip install sleepsweet # or zero-install: uvx sleepsweet run
sleepsweet run
No configuration. run scans (read-only), prints the summary below, then asks once — Apply them? [y/N] — and on y applies the fixes with a live log of every change. Nothing changes without your y:
SleepSweet — memory audit — 89 files, 206 records
Scope: all agent memory on this machine (scanned from ~/projects/myapp)
Read-only scan: nothing was changed.
20 findings: 16 warnings, 4 notices
10 broken links [[links]] pointing at memories that do not exist
6 dead file paths memory refers to files that no longer exist
3 unclear entries too short or context-dependent to stand on their own
1 duplicates the same rule or fact written more than once
0 conflicts needs a judge — run via MCP, or set SLEEPSWEET_LLM
The whole CLI:
sleepsweet run # scan + report + one confirmation + fixes
sleepsweet report # the latest report (--details for every finding)
sleepsweet diff # what changed in memory since the previous run
sleepsweet undo # revert applied fixes (--to DATE rolls back to a date)
sleepsweet asof 2026-08-01 # what the agent knew at that date
Why
Agent memory degrades measurably, and the research is unambiguous:
- Memory systems fail at conflict resolution. On the MAB FactConsolidation benchmark, popular memory stores resolve conflicting facts 7–28% of the time (best system: 54%). The recipe that reaches 78–94.8% is the one SleepSweet implements: an LLM extracts candidates verbatim, deterministic code makes the decision (arXiv 2606.01435).
- 97.7% of memory errors are born at write time — confident fabrications stored as fact (MemGuard, arXiv 2605.28009). Auditing what was written is the highest-leverage intervention.
- Bad context files actively hurt: degraded CLAUDE.md-style files reduce agent task success (arXiv 2602.11988). That is why every SleepSweet fix is a diff you approve, never an automatic rewrite.
What it checks
| Analyzer | Finds | LLM needed |
|---|---|---|
| exact_dedup | byte-identical records, within and across files | no |
| semantic_dedup | near-duplicates via static embeddings — the model ships inside the package, works offline out of the box | no |
| reality_check | paths that no longer exist — and where they moved, with filesystem-level proof (inode + birth time) when available | no |
| lineage | broken [[wiki-links]] between memories |
no |
| staleness | records far past the freshness half-life of their type | no |
| trust | weak provenance: inferred origins, anchors that no longer resolve | no |
| quality | entries that cannot stand on their own: dangling pronouns, fragments, relative dates with no anchor | no |
| conflicts | records that disagree about the same fact, resolved by newest-wins | judge* |
* The judge is either the calling agent itself (via MCP — no setup at all) or any LLM you already have via one string: SLEEPSWEET_LLM=claude (or claude:<model>), ollama:qwen3:8b, command:llm -m gpt-4o-mini, or https://host/v1#model (+ SLEEPSWEET_API_KEY if the endpoint needs one).
Run it from your agent (MCP)
claude mcp add sleepsweet -- sleepsweet mcp
The agent gets tools to scan, read the structured report, dismiss false positives, and — through get_judge_batches / submit_judged_facts — act as the conflict judge itself. No API key, no model configuration: the model that calls the tool is the model that judges. The JSON report schema is stable and documented in docs/report-schema.md.
Audit superpowers
sleepsweet diff— what changed in your memory since the previous run? Byte-level diffs of every change, with the ones SleepSweet did not make labeled as such.sleepsweet asof 2026-08-01— what did the agent know on that date? The event-sourced journal replays to any moment, and every verdict records which analyzer, ruleset, judge, and prompt produced it.
Safety
- Local-first: no telemetry, no network calls; your memory never leaves the machine (the only exception is an LLM judge you explicitly configure).
- Nothing changes without your
y: scanning is read-only, fixes wait for one explicit confirmation — or an explicit--yesfor hooks and automation — and are logged as they are applied (agents triage the same way through MCP). - Secrets are redacted before anything is stored or sent anywhere — API keys, tokens, and private keys never reach the journal or a judge.
- Everything is reversible: append-only journal,
sleepsweet undo(down to a date with--to), and history is marked, never deleted.
Details: docs/safety.md · docs/how-it-works.md · docs/cli.md · docs/mcp.md · docs/faq.md
Verified against a stratified golden set
Beyond unit tests, evals/ holds a hand-labelled,
stratified golden set: 18 kinds of memory defect (duplicates, conflicts,
moved paths, stale facts, broken links, retracted parents, trust lows,
external edits, …) covering every analyzer stage A1–A14, each with several
planted corpora and negative controls. python evals/run.py executes real
scans over them and reports objective precision/coverage per stratum and per
stage; gated strata must score clean or the run fails, while the hard strata
(vector-close lookalikes, hidden paraphrases, indirect conflicts) honestly
map the current frontier. Judge-only defects count as misses in a judgeless
run, so the tier-0 and --llm numbers are directly comparable.
Project family
- sleepsweet — engine + CLI + MCP server (this repository)
- auditable-memory-record — open specification for auditable agent memory records
- memory-hygiene-bench — open benchmark measuring the cost of dirty agent memory
License
Apache-2.0
Recommended Servers
playwright-mcp
A Model Context Protocol server that enables LLMs to interact with web pages through structured accessibility snapshots without requiring vision models or screenshots.
Magic Component Platform (MCP)
An AI-powered tool that generates modern UI components from natural language descriptions, integrating with popular IDEs to streamline UI development workflow.
Audiense Insights MCP Server
Enables interaction with Audiense Insights accounts via the Model Context Protocol, facilitating the extraction and analysis of marketing insights and audience data including demographics, behavior, and influencer engagement.
VeyraX MCP
Single MCP tool to connect all your favorite tools: Gmail, Calendar and 40 more.
graphlit-mcp-server
The Model Context Protocol (MCP) Server enables integration between MCP clients and the Graphlit service. Ingest anything from Slack to Gmail to podcast feeds, in addition to web crawling, into a Graphlit project - and then retrieve relevant contents from the MCP client.
Kagi MCP Server
An MCP server that integrates Kagi search capabilities with Claude AI, enabling Claude to perform real-time web searches when answering questions that require up-to-date information.
E2B
Using MCP to run code via e2b.
Neon Database
MCP server for interacting with Neon Management API and databases
Exa Search
A Model Context Protocol (MCP) server lets AI assistants like Claude use the Exa AI Search API for web searches. This setup allows AI models to get real-time web information in a safe and controlled way.
Qdrant Server
This repository is an example of how to create a MCP server for Qdrant, a vector search engine.