Skip to content

Sonny: the nightly cleanup reflects on habits, from what the person wrote and sent - #403

Merged
lydakis merged 5 commits into
mainfrom
claude/project-thread-u2fp8q
Oct 30, 2026
Merged

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

Conversation

@lydakis

@lydakis lydakis commented Oct 30, 2026

Copy link
Copy Markdown
Owner

Requested by George · project thread

The nightly memory cleanup now also reflects on habits: costly moves the person keeps making. A lead started in a later conversation can then name the pattern instead of the single instance. George chose this design ("Build A, your words only") after the coaching eval for #394: across six runs the leads never saved a habit to memory, so prose in the role file alone does not make habits persist.

What changes

  • Habit step in the memory-cleanup skill (new step 5). The cleanup looks across three things: what the person wrote to agents (said), the facts memory already holds, and what they sent in their chat, mail and the like, when they have connected MCP servers for those.
    • It looks for a move that cost them and that they made again.
    • Each habit is saved as a user fact with the dates it was seen, a count and what it cost. The fact is removed when the person's words show the habit stopped.
    • It also saves how the person took work an agent did unasked. This is the per-person setting that controls how far leads go on their own (Sonny: a lead starts what the person said they will do when nothing owns it #399).
    • It reads only what the person sent, sends nothing and saves nothing about other people.
  • memory changed counts the person's words. Sonny answers changed (from the script and from the memory tool). It returns true when memory changed, or when the person wrote to any agent since the last finished cleanup started (.said). A night with no saves no longer skips the reflection. A night with no saves and nothing written still costs no turn.
  • Trigger --start agents get Sonny's declared tools, the ones a task gets: the memory tool, and exec while an MCP server is on. With these, the cleanup reaches the person's servers. Saves made after an MCP read get the existing external mark.
    • An agent made by a trigger before this change gets the tools at its next fire.
    • From then on, the lookout's refresh keeps its tools current.
    • Their mode does not change: trigger agents had no gates before and still have none.

Prior art

  • Generative Agents' reflection (Park et al. 2023).
  • Letta's sleep-time agents.
  • ChatGPT memory, which looks across conversations.
  • Pulse, which remembers the person's feedback.

Habit coaching itself has no industry precedent, so the eval decides whether it works.

Security edge

Trigger --start agents are made with no gates and no sandbox. That was already true before this PR, and they already had the shell and web search. With this PR, the cleanup can also read mail through exec, which widens the prompt-injection surface. I'll file an issue proposing that trigger agents be made the way sonny --new makes them: auto plus a sandbox. That change needs testing on a Mac, because the memory script must still reach the daemon socket from inside the sandbox.

Not evaluated yet

The two-day eval comes next. Day 1 is the scripted day as before, then the cleanup runs, then day 2 starts with a fresh lead. The eval checks whether that lead names the habit at the first unread merge. It also covers #399's commitments, and removes the triggers it creates.

Checks

  • cargo test -p sonny: a_night_the_person_wrote_is_cleaned_up_though_no_agent_saved (gate on the person's words, trigger prompts ignored).
  • tests.test_trigger: a --start agent is made with Sonny's tools, and one that has none takes them at its next fire (all 25 pass locally).
  • Clippy and the sonny and agent-client test suites.
  • No daemon, protocol or schema change.

Generated by Claude Code

…son wrote and sent

The memory-cleanup skill gains a habit step: a costly move the person
made again, from said, memory and, through exec, their chat and mail,
saved as a user fact with dates and a count; and how they took work done
unasked. memory changed is also true when the person wrote since the
last cleanup, and trigger --start agents get Sonny's declared tools.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_013jkdGEbQZnXUy1kATtYcQ6
@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Oct 30, 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-30T02:23:13.389337Z 1d2ac4c New commits
🔒 Security Review ✅ Completed 2026-10-30T02:28:36.631395Z 1d2ac4c 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.

ℹ️ 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 sonny/src/said.rs Resolved
Comment thread sonny/src/trigger.rs Resolved
…tarts a stopped daemon

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_013jkdGEbQZnXUy1kATtYcQ6
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_013jkdGEbQZnXUy1kATtYcQ6
@lydakis
lydakis merged commit 91d7150 into main Oct 30, 2026
4 checks passed
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