Skip to content

Memory: no index cap, agents start with its head; work facts; search - #686

Merged
lydakis merged 2 commits into
mainfrom
claude/project-thread-0dikvb
Nov 5, 2026
Merged

lydakis merged 2 commits into
mainfrom
claude/project-thread-0dikvb

Conversation

@lydakis

@lydakis lydakis commented Nov 5, 2026

Copy link
Copy Markdown
Owner

🤖 Generated with Claude Code

https://claude.ai/code/session_013jkdGFAkmSC4c8JiLYXBrd

Why

A busy project's MEMORY.md hit its 16 KiB cap mid-day. Two things drove it. Agents had nowhere else durable to keep work in flight, and every index went whole into each agent's instructions, which are capped at 60 KiB. Saves were refused with memory_full, and the refusal told working agents to merge or remove facts. That is the nightly cleanup's job, not theirs. Every mature system bounds what gets preloaded rather than what gets saved: Claude Code loads the first 200 lines or 25 KB, and Codex loads a small summary plus its most-used facts.

What changes

All of this is client-side, so there's no protocol or schema change.

  • No cap on the index; agents start with its head. MEMORY.md lists every fact, most needed first. Work under way comes first, by name on one line, then user and feedback, then the rest. Within each group, the most confirmed and then the most recently verified come first. A new agent's instructions and show take the first 16 KiB of each index (memory::head), then a line saying how many facts it leaves out. A save is never refused for room, and nothing tells agents how full memory is.
  • A work type. It holds work under way that a later agent may pick up. The index lists work facts by name only. cleanup start lists the ones not saved in over three days as stale_work. The cleanup skill retires them after saving any lesson they hold as a fact of its own. The loss guard leaves work facts out of both of its counts.
  • search. memory search WORDS... [SCOPE] and the tool's search field look across both scopes. They return at most 20 facts whose file holds every word (case-insensitive), best first, each with its index line and up to three matching lines.
  • Text for agents. The memory skill covers the ordering, the head, search and work, and drops the merge-on-refusal paragraph. The cleanup skill gets a stale-work step. lead.md now saves work under way as a work fact, within its byte budget. The tool schema and description, docs/SONNY.md and the FEATURES row are updated to match.

Retiring lasting facts by age is left out on purpose. With only the head loaded it isn't needed for room, and removing facts on age alone can lose true ones.

Checks

  • cargo fmt, cargo clippy --locked --workspace --all-targets -- -D warnings
  • cargo test -p agent-client: 98 pass. cargo test -p sonny: all pass.
  • New tests:
    • 400 saves all land, and the head says how many facts it leaves out
    • a 2,000-fact index goes into instructions as its head
    • work comes first by name, stale_work is listed, and retiring work passes the loss guard
    • search ranking and matching lines, from the CLI and from the tool

Generated by Claude Code

A project's MEMORY.md filled its 16 KiB cap mid-day, and the refusal told
working agents to merge or remove facts to make room. Now:

- An index lists every fact, most needed first: work under way by name,
  then the person's own facts, then the rest, by confirmations and date.
  New agents and `show` take each index's first 16 KiB plus a line saying
  how many facts it leaves out. A save is never refused for room.
- A `work` type for work under way. The index names it only; cleanup
  start lists work unsaved for over three days as stale_work, the cleanup
  retires it after keeping any lesson, and the loss guard leaves work out.
- `memory search WORDS` (and the tool's `search`): facts holding every
  word across both scopes, best first, with their matching lines.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_013jkdGFAkmSC4c8JiLYXBrd
@lydakis lydakis self-assigned this Nov 5, 2026
@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Nov 5, 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-11-05T02:55:55.066432Z c17ad50 New commits
🔒 Security Review ✅ Completed 2026-11-05T02:51:33.058226Z 21472a9 PR opened
ℹ️ 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: 21472a997a

ℹ️ 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 client/src/memory.rs Resolved
Comment thread client/src/memory.rs Resolved
Comment thread client/src/memory.rs Resolved
…bound kept on save

Review fixes for the uncapped index:
- Each work fact is its own index line (name and date), so the head keeps
  as many as fit rather than losing them all with one long line.
- `changed` is true while a work fact is stale, so a quiet night still
  wakes the cleanup that retires it; work still under way is saved again.
- A folder may hold 16,384 entries, and a new fact's save is refused at
  that bound, so no save leaves a folder the other commands cannot read.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_013jkdGFAkmSC4c8JiLYXBrd
@lydakis
lydakis merged commit e1ab53b into main Nov 5, 2026
10 checks passed
@lydakis
lydakis deleted the claude/project-thread-0dikvb branch November 5, 2026 03:20
@lydakis lydakis mentioned this pull request Nov 5, 2026
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