Repository navigation
Write Pi's summary at the extension's threshold - #4
Merged
Merged
Conversation
Anthropic invalidates the cached message prefix when tool_choice or thinking parameters differ from the conversation's requests. Handoff notes sent toolChoice "none" without reasoning, so in the recorded sessions they read only 5-14% of their prompt from cache (3.96M of 20.5M tokens over 170 notes). A reply that calls a tool is now rejected, since tool use is no longer disabled.
Pi's own compaction waits for contextWindow - reserveTokens, about 983k tokens on 1M-window models. When the handoff note failed, did not fit, or soft came first in methodOrder, thresholdTokens therefore did not compact, and a context-window cap was needed to compact at 150k. soft now writes Pi's summary at end of turn when the extension's threshold is below Pi's, so the run is not aborted. Like Pi, it updates the previous summary instead of summarizing it as history, writes nothing when no history precedes the retained context, and does not retry a failed summary until the next compaction.
# Conflicts: # CHANGELOG.md
HugoLopes45
added a commit
that referenced
this pull request
Oct 6, 2026
The old README assumed knowledge of compaction, tokens and thresholds. This rewrite, in ASD-STE100 style: - explains the terms and the sequence of a session; - documents every `contextKit` setting with its allowed values, default and an example; - adds recipes, limits and questions. Checked against the code: - Defaults, validation rules and the warning text match `src/config.ts` and `extensions/index.ts`. - `soft` writes Pi's summary at the extension threshold (#4). Only `[]` waits for Pi's own limit. - The release section is unchanged from #5.
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.
Stacked on #3. Merge #3 first; GitHub then retargets this PR to
main.Why
Pi compacts at
contextWindow - reserveTokens, about 983k tokens on 1M-window models.thresholdTokenscompacted only through a handoff note. When the note failed or did not fit, or whensoftcame first inmethodOrder, nothing compacted until Pi's own threshold. A separate context-window cap extension was needed to compact at 150k.Change
softwrites Pi's summary (generateSummaryWithUsage) at the end of the turn. It does this when the context is still above the extension's threshold and that threshold is below Pi's. The run is not aborted.Tests
New integration tests in
test/extension.test.ts. Each one fails without the change it covers.softis not inmethodOrderor when the threshold equals Pi's.<previous-summary>update prompt.npm run check: 97/97 passed.