Skip to content

Memory: a strategy entry type and memory_distill, the ReasoningBank layer above facts - #431

Merged
currentbits merged 9 commits into
mainfrom
coder/memory-distill-procedural-strategy-entri-f14749
Aug 18, 2026
Merged

currentbits merged 9 commits into
mainfrom
coder/memory-distill-procedural-strategy-entri-f14749

Conversation

@currentbits

Copy link
Copy Markdown
Owner

Closes #308.

ReasoningBank (arXiv 2509.25140) shows that distilling reusable strategies from past trajectories — successes and failures both, with failures carrying much of the gain — beats plain fact memory. Solenta's memory already had episodic (run), semantic (knowledge) and standing rules (convention), but no procedural layer. This adds one.

A fifth entry type: strategy

A short "when doing X, do/don't Y" rule, importance 4 — above knowledge (3), below convention (5). memory_bootstrap gains a strategies section that agents get at session start, injected whole under a 500-token budget: a rule truncated mid-clause is worse than an absent one. The protocol tells agents to follow strategies and to report a bad one with memory_feedback.

Widening entries.type needed care. SQLite cannot ALTER a CHECK constraint, so widenEntryTypes() does the table rebuild — but it reuses the DB's own DDL with only the CHECK list swapped, rather than writing out a fresh full schema. That preserves each DB's exact column set, so the addColumnIfMissing migrations below it still fire and still backfill. Building the new table from the current schema instead silently skipped the importance backfill on pre-importance DBs; db.test.js caught it.

memory_distill

The memory server has no LLM and should not grow one, so distillation is agent-driven, in the same shape as the existing memory_maintenance: the server hands over evidence plus a short instruction list, and the calling agent writes the rules with memory_store({ type: 'strategy' }).

distill({ project }) returns { failures, successes, existing, instructions }:

  • failures — live entries with harmful_count > 0 carrying their most recent feedback_log notes, plus abandoned tasks. This is the high-value signal: places where an agent was actually misled.
  • successes — live run entries from the last 14 days and entries with helpful_count > 0.
  • existing — strategies already stored, so the agent can see what is covered.

Every list is project-scoped and live-only, capped at 20 with the true total reported alongside so nothing truncates silently. The call is read-only: no writes, no markAccessed, no watermark. Restating a known strategy is already a no-op thanks to store-time Jaccard dedup, so no new state was needed to make it idempotent.

App surface

strategy flows through MemoryEntryInfo, gets its own badge in the Memory tab, is creatable from the store form, and is seeded in the dev provider. No new UI — no distillation button, no new panel. The electron memory proxy has no type allowlist, so there was nothing to widen there.

Testing

Beyond each side's own tests, test/rest.test.js covers the join the app actually depends on: a strategy stored over REST (how the Memory tab writes) coming back out of both memory_bootstrap and memory_distill over MCP.

  • memory 173/173, renderer 913/913, core 38/38, tsc --noEmit clean
  • electron 1159/1160 — the failure is the pre-existing wireClient × webBridge over a real socket baseline on main, unrelated to this change

Deliberately left out

No automatic distillation schedule: the janitor stays dumb and an agent calls memory_distill when it wants the pack. No server-side LLM. Both are easy to add on top if the manual loop proves worth automating.

  • PR created by the Claude Code agent

Willem and others added 9 commits August 18, 2026 08:22
… The left bar has too many option we need to move a few. Perh
Shared contract for the ReasoningBank work: a fifth entry type for distilled
"when doing X, do/don't Y" rules, ranked between conventions and knowledge.

- widenEntryTypes rebuilds the entries table on old DBs (SQLite cannot ALTER a
  CHECK), reusing the DB's own DDL so the later column migrations still fire
- bootstrap gains a `strategies` section, whole-body under a 500-token budget
- protocol line tells agents to follow strategies and report bad ones

Co-Authored-By: Claude Opus 5 <[email protected]>
… Memory: synthetic state-change regression test
Widen MemoryEntryInfo, the Memory tab badge/store form, and the dev seed
so strategy entries render distinctly and can be created. Electron proxy
has no type allowlist — left untouched.

Co-Authored-By: Claude Opus 5 <[email protected]>
)

The server has no LLM, so it does not write type:strategy rows. distill()
is a read-only report in the same shape as maintenance(): it hands the
caller the raw evidence plus a short instruction list, and the agent
writes the "when doing X, do/don't Y" rules with memory_store.

Failures (highest-value signal): live harmful_count > 0 entries with
their most recent feedback_log notes, plus abandoned tasks. Successes:
live runs from the last 14 days and helpful_count > 0. Existing: titles
of live strategies already stored, so the agent can see coverage.
Each list is project-scoped, live-only, capped at 20, with the true
total reported alongside. No watermark — store-time dedup is what
makes restating a known strategy a no-op.

Co-Authored-By: Claude Opus 5 <[email protected]>
…into coder/memory-distill-procedural-strategy-entri-f14749
#308)

The app writes strategies over REST and agents read them over MCP; each side
was only covered against its own fake. One test drives the real join, plus a
README entry-type table.

Co-Authored-By: Claude Opus 5 <[email protected]>
@chatgpt-codex-connector

Copy link
Copy Markdown

You have reached your Codex usage limits for code reviews. You can see your limits in the Codex usage dashboard.

@currentbits
currentbits merged commit c31a567 into main Aug 18, 2026
1 check failed
@currentbits
currentbits deleted the coder/memory-distill-procedural-strategy-entri-f14749 branch October 3, 2026 16:07
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.

Memory: distill procedural strategy entries from successes and failures (ReasoningBank pattern)

1 participant