fix: re-add HOW_TO_COMPRESS_RULES to nudge injection - #245
Merged
Conversation
…on summary guidance
v1.14.7 removed HOW_TO_COMPRESS_RULES from nudge to save ~2.4K tokens/turn,
keeping it in system prompt only. But in 8700+ message sessions, the system
prompt is 12K chars buried at the START of 1M+ token context — the model's
attention to the rules degrades ('lost in the middle' effect). When the nudge
fires and the model needs to write summaries, the detailed rules (KEEP VERBATIM,
DROP, PRIORITY) are not at high attention.
Re-add HOW_TO_COMPRESS_RULES to nudge text: non-maxLimit path (before ranges
list) and maxLimit path (in strong alert). +5K chars per nudge, but nudges
are gated by nudgeGrowthTokens — not every turn. Better summaries = fewer
recompressions = net token savings.
This was referenced Jul 30, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Problem
v1.14.7 (PR #228) removed
HOW_TO_COMPRESS_RULESfrom nudge templates to save ~2.4K tokens/turn. Rules kept in system prompt only.But in 8700+ message sessions, the system prompt (12K chars) is buried at the START of a 1M+ token context. The model's attention to rules at the beginning degrades — the "lost in the middle" effect. When the nudge fires and the model needs to write summaries, the detailed rules (KEEP VERBATIM, DROP, PRIORITY) are not at high attention.
The nudge message IS at the END of context (high attention). Before v1.14.7 it contained the rules. Now it only has
COMPRESS_PHILOSOPHY(889 chars, high-level) — missing the detailed 4936-char rules for HOW to write good summaries.Evidence: session
ses_0b89319bfloor 8683 — nudge shows "Compression Philosophy" but NOT "HOW TO COMPRESS" rules.Fix
Re-add
HOW_TO_COMPRESS_RULESto nudge text in two places:inject.ts:534): Before compressible ranges list, after COMPRESS_PHILOSOPHYinject.ts:545): In strong alert tipsText, before JSON exampleTradeoff
+5K chars when a nudge fires (gated by nudgeGrowthTokens — NOT every turn). Better summaries = fewer recompressions needed = net token savings.
Verification