Skip to content

fix: keep a block in view when its preview would tell the model too little - #17

Merged
hardy30894 merged 2 commits into
mainfrom
fix-short-generic-offload
Oct 23, 2026
Merged

hardy30894 merged 2 commits into
mainfrom
fix-short-generic-offload

Conversation

@hardy30894

Copy link
Copy Markdown
Member

Why

Running the mod in a real session, small results kept coming back as an 80-character head preview, [559 bytes offloaded, preview: valid bindings/...], hiding exactly the lines needed: a list of checks, a version, a count. Of the twelve real offloads in that session that had only a head preview, four of the six under 2 KB had to be fetched back, against one of the six above.

secondwind eval now records each offload's preview kind. On 1,491 recorded sessions:

preview size reopen rate context saved
prose digest every size 34 to 80% -14% to +3%
first line only under 1 KB 16% 59%
first line only 1 to 2 KB 27% 60%
code outline 1 to 2 KB 22% 55%

The prose digest never pays. For small head-only blocks the corpus measure looks good, but it counts a reopen only when the model later quotes a hidden token, and the result of a short check is read for a decision rather than quoted; the session above shows reopens about three times higher than the measure for those blocks.

What

offload::worth_offloading decides from the preview a block would get: a prose digest is never offloaded, and a block whose only preview is its first line is offloaded only from 2 KB. Such a block stays in view, and inline codecs still apply. The refusal is booked as thin_preview. Blocks under the store's 512-byte minimum keep their old label. Byte-identical repeats, JSON relevance splits and opt-in prose mode are unchanged.

Trade-off, held-out half, Claude Code mod's path (Bash, gated)

context saved billed cost saved reopens per session
before 8.6% 15.1% 4.5
prose digests in view 8.3% 14.7% 3.9
+ head-only under 1 KB 7.2% 12.5% 3.2
+ head-only under 2 KB (this PR) 5.2% 8.8% 2.3

Reopens halve; token savings drop by about 40% on the corpus measure, which undercounts these reopens. MIN_HEAD_OFFLOAD_BYTES is the dial: 1 KB keeps more savings and removes fewer turns. Every replay: 0 unfaithful blocks.

Tests

A new test pins that a short head-only status listing stays in view through the optimizer, that the same listing at four times the size still offloads, that prose stays in view, that code still offloads with its outline, and that tiny blocks keep their old label. Four existing tests used prose as their offloadable fixture; they now use code lines, which keeps what each tests (offload mechanics, the cache guard, replay). Optimizer: 288 passed; CLI: 29 passed. Clippy clean.

The stub's label names what the model saw in place of the block: diff summary, match map, code outline, content table, json index, prose digest, or only the first line. --blocks now writes it per result.
…ittle

On 1,491 recorded sessions a prose digest was reopened 34 to 80% of the time for no net saving, and in this session's real stubs four of six blocks under 2 KB shown only by their first line had to be fetched back. Such blocks now stay in view, booked as thin_preview; repeats, relevance splits and prose mode are unchanged. Held out, on the mod's path, reopens per session fall from 4.5 to 2.3 and the context saving from 8.6% to 5.2%. Tests that used prose as their offloadable fixture now use code, which still offloads with an outline.
@hardy30894
hardy30894 merged commit fee33f5 into main Oct 23, 2026
3 checks passed
@hardy30894
hardy30894 deleted the fix-short-generic-offload branch October 23, 2026 03:24
@hardy30894 hardy30894 mentioned this pull request Oct 23, 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.

1 participant