Skip to content

Prefrontal memory: explain it to agents, measure reading, gate SUBMIT for issue finders - #64

Merged
khezen merged 7 commits into
mainfrom
feat/prefrontal-memory-read-coverage
Nov 25, 2026
Merged

khezen merged 7 commits into
mainfrom
feat/prefrontal-memory-read-coverage

Conversation

@khezen

@khezen khezen commented Nov 24, 2026

Copy link
Copy Markdown
Owner

Problem

Every RLM agent receives prefrontal_memory as a REPL variable, but the prompt only shows a 1,000-char head+tail preview of it. On peaks-com/mono#10519 the memory was ~68k chars, so the preview was ~1.5% of it. No prompt mentioned memory, nothing measured whether it was read, and nothing gated SUBMIT on it. The diff had the same problem before the coverage gate in #62.

Changes

  • Prompt (all 9 agents that get memory): with_prefrontal_memory appends a MEMORY block to the instructions. It covers:
    • what memory is (read-only, may be stale) and what each section holds;
    • how to use it: read it first, check recurring patterns against the changed files, and respect recorded decisions;
    • never report an issue from memory alone, and trust the code when the two disagree.
  • SUBMIT gate (code_review, doc, seo, supply_chain): with require_read=True, the prompt tells the model to print the memory in slices under the output cap. memory_check sends an early SUBMIT back with the unseen section titles and the exact prefrontal_memory[a:b] slices to print.
    • Adjacent sections are merged into one slice, and long ranges are split under the cap.
    • code_review combines the file and memory gates into one rejection (combine_checks).
    • Once max_iters / max_llm_calls is spent, SUBMIT is accepted. The ContextSafe fallback gets the same gate.
    • No config toggle, same as the diff gate.
  • Measurement (all 9 agents): the coverage INFO line gains memory_seen=<seen>/<total> sections (unseen: …).
    • A section counts as seen when 90% of its lines appear in what the model saw, the same rule as unseen_files.
    • The memory is split only on the section titles codespy renders (format.is_section_title), so headings inside briefings or reflect answers stay in their section.
  • Docs and changelog: docs/memory.md gains a "Delivery to agents" subsection and a log example. CHANGELOG has a ### Changed entry under Unreleased, with no version bump.

Cost

The 4 gated agents now print the whole memory, which adds its size (~17k tokens on mono#10519) to every later step's prompt in each scope run.

Tests

tests/test_memory_coverage.py adds 48 tests: section parsing and round-trip, unseen sections, slices under the cap, the combined gate, CodespyRLM reject and accept, logging, the prompt blocks and cache, and agent wiring. The full suite has no new failures: 40 failed and 3 errors, the same tests as on main.

Validation still to do

Re-run on peaks-com/mono#10519 and check:

  • gated agents reach memory_seen=y/y or log the budget-spent acceptance;
  • coverage_rejections, cost and latency compared with the previous run;
  • any new content_filter refusals.

@khezen
khezen merged commit 4c3d9a7 into main Nov 25, 2026
6 checks passed
@khezen
khezen deleted the feat/prefrontal-memory-read-coverage branch November 25, 2026 01:53
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.

1 participant