Skip to content

Tell the memory condenser how many bytes its summary may take - #48

Merged
aaroncoville merged 3 commits into
theme/sixth-historyfrom
fix/condense-byte-target
Oct 12, 2026
Merged

aaroncoville merged 3 commits into
theme/sixth-historyfrom
fix/condense-byte-target

Conversation

@aaroncoville

Copy link
Copy Markdown
Owner

What & why

Memory condensing kept aborting with not-smaller: the summary model rewrote the condensed history at greater length than the material it replaced, so the rebuilt file came out larger than the original and the size check discarded it. The files that most needed shrinking never shrank.

The prompt never said how much room the summary had. Its only size hint was "Target <= 1500 words", which has nothing to do with the file being condensed. This PR computes the room and states it. The rewrite should come out at no more than 80% of the original. The header, the pinned facts and the newest sections kept verbatim are a known size, so the condensed section gets whatever is left. The prompt gives that number, in bytes, as a hard ceiling (a new input (D) SIZE LIMIT).

The existing not-smaller check is unchanged and remains the backstop for a model that ignores the limit. The keep-set byte budget and the model are untouched.

Type of change

  • Bug fix
  • New feature
  • Refactor / cleanup
  • Docs
  • Build / CI

Evidence

This change has no UI. The evidence is the new tests going red, then green.

Before

New tests run against the unchanged reflect.ts:

not ok 1 - the prompt states a byte limit that, met exactly, leaves the file at 80% of its size
  error: 'the prompt must carry a positive byte limit for the condensed section'
not ok 2 - the byte limit tracks the size of the file being condensed
ok 3 - a summary that ignores the byte limit and does not shrink the file still aborts
# pass 1
# fail 2

After

$ node --test test/reflect.test.cjs test/reflect-summary.test.cjs
# pass 38
# fail 0

Full suite (npm run test:focused): 1760 of 1762 pass, 0 fail, 2 skipped. The baseline on the base commit was 1756 of 1759, with 2 skipped and one pre-existing failure in test/proc-kill.test.cjs, which passed on this run.

Mutation check: each of these changes to reflect.ts turns at least one new test red. All 5 are caught:

  • ratio 0.8 → 0.9
  • not subtracting the verbatim regions
  • a constant limit
  • dropping the limit line from the prompt
  • a limit 500 bytes tighter than the room available

How I tested it

  • OS: macOS (Darwin 27.0.0)
  • Steps:
    • npm run typecheck: 0 errors.
    • npm run test:focused: the result above.
    • npm run build: succeeds.
    • The first new test stubs the model to use every byte the prompt allows. It asserts that the rebuilt file then lands at 80% of the original, give or take 2 bytes.

Memory condensing kept aborting with `not-smaller`: on most runs the
summary model rewrote the condensed history at greater length than the
material it replaced, so the rebuilt file came out 20-40% larger than
the original and the size check (correctly) discarded it. Files that
most needed shrinking never shrank.

The prompt never said how much room the summary had. Its only size hint
was "Target <= 1500 words", which is unrelated to the file being
condensed: for a file whose verbatim regions already fill most of it,
1500 words is more than the whole budget, and a model aiming for the
hint grows the file.

Compute the room instead and state it. The rewrite should come out at no
more than 80% of the original; the header, pinned facts and the newest
sections kept verbatim are a known size, so the condensed section gets
whatever is left, and the prompt gives that number as a hard ceiling.
The existing not-smaller check stays as the backstop for a model that
ignores the limit.
@github-actions

Copy link
Copy Markdown

🚫 This PR is missing its before/after evidence

Every pull request here has to show its work. Screenshots or a short screen recording, before the change and after it.

  • Before — no image or video under that heading
  • After — no image or video under that heading

How to fix it: edit the description, keep the ### Before and ### After headings from the template, and drag an image or video under each. GitHub uploads it inline. This check re-runs the moment you save.

A bug fix with no visible surface still needs it: show the failing behaviour, then the same steps passing. A terminal recording is fine.

Genuinely nothing to show — a CI tweak, a typo, a dependency bump? A maintainer can apply the no-visual-change label. Please don't ask unless it truly has no observable effect.

📖 CONTRIBUTING.md → Evidence is mandatory

Aaron Coville added 2 commits October 12, 2026 10:42
…e target is out of reach

The condense prompt states how many bytes the summary may take: what is
left of 80% of the file once the regions kept verbatim are counted. On
files whose pinned facts and newest sections already take more than 80%
of the file, that came to nothing, and the prompt told the model it had
0 bytes. A model that obeyed wrote an empty summary, which fails to
parse, so the condense failed without setting the not-smaller backoff
and was paid for again on every scan, indefinitely. The rewrite those
files could still take (anything under 95% of the old size, the size
check's own limit) was never asked for.

When the 80% target is out of reach, state the room the size check
allows instead, less a fixed allowance for pinned facts the summary may
hoist (they are not known until it returns). When even that leaves no
room, no summary could be accepted: skip the call and set the same
backoff a not-smaller result sets, so the autonomous scan stops paying
for it until the file grows.
@aaroncoville

Copy link
Copy Markdown
Owner Author

Review round 1 addressed in 700e609 (refactor: name the 95% acceptance ratio) and 83cde92 (fix). When the verbatim regions leave no room for the 80% target, the stated limit falls back to the room the size check allows, less 512 bytes for hoisted facts. When even that is 0, no summary is requested and the not-smaller backoff is set. Two new tests, both RED first. 6 of 6 mutants killed (no allowance, no skip, no backoff, no fallback, always fallback, an off-by-600 accepted room). Suite 1762 of 1764, 0 fail, 2 skipped; typecheck clean.

@aaroncoville
aaroncoville merged commit 842dc24 into theme/sixth-history Oct 12, 2026
1 check failed
@aaroncoville
aaroncoville deleted the fix/condense-byte-target branch October 12, 2026 14:48
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