Skip to content

Memory: nightly cleanup as a skill and a gated trigger - #123

Merged
lydakis merged 5 commits into
mainfrom
claude/project-thread-k9p3ok
Oct 10, 2026
Merged

lydakis merged 5 commits into
mainfrom
claude/project-thread-k9p3ok

Conversation

@lydakis

@lydakis lydakis commented Oct 10, 2026 •

Copy link
Copy Markdown
Owner

Before: memory only grows. Agents save facts, nothing merges duplicates or drops superseded ones, and the 4 KiB index eventually refuses saves with memory_full.

After: ~/.agent/memory schedule --model PROVIDER/MODEL adds a nightly trigger, memory-cleanup. At 03:30 (--cron moves it) it starts an agent in ~/.agents/memory that follows the new memory-cleanup skill: merge duplicates, drop superseded facts, date relative ones, using only save and rm. A night when nothing was saved or removed costs no turn, because the trigger's --if runs memory changed.

The daemon is unchanged. The cleanup is a skill plus a T1 trigger plus three script verbs:

  • memory changed exits 0 only when the folder differs from the last commit.
  • memory cleanup start makes ~/.agents/memory a local git repository (never pushed) and commits what agents saved. It returns the facts saved and removed since the last cleanup, which the agent reads first instead of every fact.
  • memory cleanup finish commits the cleanup and returns what it removed, added and changed. If the cleanup removed more than a quarter of the facts (and more than two), finish reverts it with a new commit (loss_guard). Memory goes back to how it was, and the refused cleanup stays in history.

Plan picks and departures

  • Decision Rewrite README with quickstart guide and add dual licensing #6(c), "nightly cleanup on by default": this one is one command, not on by default. The app has no default model, so it can't pick one for the person. When George runs schedule, it is on from then on. M3's memory panel could offer it as a toggle.
  • The research suggested a fresh agent per night. This PR follows George's 2026-09-28 decision instead: a schedule wakes one existing agent, and compaction bounds its context. Because each call carries earlier nights up to compaction, the per-turn cap is 1,000,000 tokens rather than something tighter.
  • Deferred from the research: skill proposals into inbox/, removing facts for stale verified dates (the skill forbids removing a fact for age alone), and posting the diff to the app (the agent's reply carries it, and M3 owns the app side).

For M3 (Rich rendering thread)

~/.agents/memory now holds .git/, .gitignore and, during a cleanup, .cleanup. None of them are .md, so fact listing and check ignore them. A panel listing the folder should skip dot entries too.

Checks

  • cargo fmt --check and cargo clippy -D warnings are clean (workspace and app).
  • App tests: 162 pass. One fails, remote::tests::no_ssh_config_changes_what_the_app_forces, and it fails the same way on main in this Linux container (its ssh probe).
  • node --test app/tests/*.cjs: 218 pass.
  • New tests cover the commit, the duplicate start, the saved/removed lists, the loss-guard revert and the trigger arguments.
  • No model calls were made. schedule hasn't been run against launchd, since triggers only run on macOS.

🤖 Generated with Claude Code

`~/.agent/memory schedule --model M` adds the trigger `memory-cleanup`:
at 03:30 it starts an agent in `~/.agents/memory` that follows the new
`memory-cleanup` skill, gated by `memory changed` so a quiet night costs
no turn. `cleanup start` and `cleanup finish` commit to a local git
repository in the memory folder; `finish` reverts a cleanup that removed
more than a quarter of the facts (two at least). The daemon is unchanged.

Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]>
Claude-Session: https://claude.ai/code/session_019xtP72bEUJnpaJshaUzKwG
@chatgpt-codex-connector

Copy link
Copy Markdown

You have reached your Codex usage limits for security reviews. Please try again later.

@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Oct 10, 2026 •

Copy link
Copy Markdown

Codex Review Summary

This comment shows the latest Codex review activity on this pull request.

Review Status Commit Review trigger
📝 Code Review ✅ Completed 2026-10-10T09:40:13.218601Z 25aa61d New commits
ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review" or "@codex security review".

Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings.

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: b545207ddb

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment thread app/src-tauri/src/memory.rs Resolved
Comment thread app/src-tauri/src/memory.rs Resolved
Comment thread app/src-tauri/src/memory.rs Resolved
Comment thread app/skills/memory/SKILL.md Resolved
`changed` counts an open cleanup, so a run cut short is finished the next
night. A new memory repository commits its `.gitignore` alone, so a night
with no facts costs no turn. The skill and docs say git keeps memory as it
was at each cleanup, not every version.

Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]>
Claude-Session: https://claude.ai/code/session_019xtP72bEUJnpaJshaUzKwG

lydakis commented Oct 10, 2026

Copy link
Copy Markdown
Owner Author

@codex review


Generated by Claude Code

@chatgpt-codex-connector

Copy link
Copy Markdown

You have reached your Codex usage limits for security reviews. Please try again later.

1 similar comment
@chatgpt-codex-connector

Copy link
Copy Markdown

You have reached your Codex usage limits for security reviews. Please try again later.

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 9e1ffecfd2

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment thread app/src-tauri/src/memory.rs Resolved
Comment thread app/src-tauri/src/memory.rs Resolved
Comment thread app/src-tauri/src/memory.rs Resolved
Comment thread app/src-tauri/src/memory.rs Resolved
Comment thread app/src-tauri/src/memory.rs Resolved
git for memory clears a hook's GIT_DIR and the like, as triggers' git
does, and pins line endings so a restored fact is byte for byte. The
repository is initialized shared 0600, and files a loss-guard revert
writes back are made 0600 again, as the facts are.

Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]>
Claude-Session: https://claude.ai/code/session_019xtP72bEUJnpaJshaUzKwG
@chatgpt-codex-connector

Copy link
Copy Markdown

You have reached your Codex usage limits for security reviews. Please try again later.

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: fdb6457dfe

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment thread app/src-tauri/src/memory.rs Resolved
Comment thread app/src-tauri/src/memory.rs Resolved
Comment thread app/src-tauri/src/memory.rs Resolved
`schedule` without `--model` keeps the memory-cleanup agent it started,
so moving the time after `trigger rm` works; with `--model` while that
agent exists, the refusal says how to keep or replace it. Memory's git
ignores the person's global excludes and attributes, so every fact is
snapshotted and restored byte for byte.

Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]>
Claude-Session: https://claude.ai/code/session_019xtP72bEUJnpaJshaUzKwG
@chatgpt-codex-connector

Copy link
Copy Markdown

You have reached your Codex usage limits for security reviews. Please try again later.

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 306ff8718e

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment thread app/src-tauri/src/memory.rs Resolved
Comment thread app/src-tauri/src/memory.rs Resolved
…-k9p3ok

# Conflicts:
#	app/src-tauri/src/memory.rs
@lydakis
lydakis merged commit 41bfbd8 into main Oct 10, 2026
1 check passed
@chatgpt-codex-connector

Copy link
Copy Markdown

You have reached your Codex usage limits for security reviews. Please try again later.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants