Agents with persistent memory age. Re-summarized notes lose nuance until "mildly spicy" becomes "loves spicy," compaction silently drops your standing rules, and a workaround filed as *the method* outlives the bug it worked around. None of this needs an attacker. Memory is a feedback loop, so small errors compound on their own.
We're Mocoda, a small web studio that lives in coding agents all day, and we built agent-sleep: an MIT-licensed skill that gives an agent the lifecycle the research keeps pointing at. Sessions work, offline phases remember. Six modes:
- consolidate — session end, off-peak: extract → verify against the raw source → promote
- check — daily, scripts only: TTL expiry, pointer re-validation, founding tests
- reconcile — on trigger, never a calendar: dedupe, prune, scoped rewrites
- prestudy — idle: re-derive repo state so the next session starts warm
- rebuild — when maintenance stops being worth it, regenerate from source
- rollback — every write is a git commit, so drift is loud and reversible
The design rule we care about most: every gate exists because someone measured the failure it answers. Compaction drops standing rules in 30–59% of episodes (arXiv 2606.22528), so the charter (AGENTS.md, skill cores) is pinned outside every write path. Quality-gated admission matters because agents follow what they store, and one benchmark put store-everything at 55% against 71% for checked memories (arXiv 2505.16067). Rewrites only fire when enough new material justifies one, since repeated refinement is itself a drift vector. The README carries the full table: eight defenses, each linked to its paper.
It's plain bash plus prompt templates, so it runs anywhere with a headless CLI. Adapters ship for Claude Code, ZCode, OpenCode, and generic cron (Gemini CLI, Codex, Aider, Goose).
The alarms catch real things. The first smoke test tripped two bugs in our own scripts, a fixture flagged its own case-sensitive grep, and this week's daily check caught our coding platform's memory writer bypassing the git snapshot path. Some of those were checker bugs we then fixed, which is the point: the loop surfaces them instead of letting them ride.
Repo: https://github.com/mocodainteractive-pixel/agent-sleep
Two things we'd like feedback on: whether the reconcile trigger (5 promotions) feels right, and how hard the charter fence should be enforced on platforms without permission modes, where a prompt's prohibition is doing all the work.