feat: protectedLatestTools — protect only the latest instance of a tool - #223
Open
ranxianglei wants to merge 1 commit into
Open
feat: protectedLatestTools — protect only the latest instance of a tool#223ranxianglei wants to merge 1 commit into
ranxianglei wants to merge 1 commit into
Conversation
Cumulative-snapshot tools (e.g. todo_list) keep their full state in the newest result, so every older result is strictly redundant. protectedTools over-protects them (all instances BLOCKED forever); preserveRecentMessages under-protects (N must span far enough back). New Config.protectedLatestTools (optional, glob patterns): for each pattern, only the LAST matching tool-call and its paired tool-result are protected from compression; older instances stay compressible. Superseded pairs keep their BLOCKED ref (never re-issued) but become foldable at apply time, since apply-time protection is re-checked against the current config. Wired into all protection sites: assignRefsNode (BLOCKED ref), filterProtectedToolMessages (range-apply exclusion), buildCompressibleRanges (recommendation), isAbsorbCandidate/appendAbsorbPrompts/applyAbsorb (absorb). Pre-flight: typecheck PASS; 637/637 tests (624 existing + 13 new in tests/protected-latest.test.ts); build PASS.
📦 Built Package ArtifactBranch: Option A — Install from npm PR tag (recommended)In your adapter project: npm install acp-kernel@pr-223Each push to this PR publishes a new version under the Option B — Download artifact
tar xzf acp-kernel-pr223.tgz
npm install ./packageThis comment is automatically updated on each push. |
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
Cumulative-snapshot tools (e.g.
todo_list) keep their full state in the newest result — every older result is strictly redundant. The existing mechanisms can't express "protect only the latest instance":protectedToolsover-protects: all instances are BLOCKED forever, so stale snapshots accumulate and are never compressed.preserveRecentMessagesunder-protects: N must be large enough to always span back to the newest instance.Requested by ranxianglei/billion-context#637 (todo continuity: protect, don't recall-after-compression; only the latest todo message needs protection).
Change
New
Config.protectedLatestTools(optional,string[], glob patterns via the existingmatchToolPattern): for each pattern, only the LAST matching tool-call (message order) and its paired tool-result are protected from compression; older instances remain compressible.BLOCKEDref (refs are never re-issued) but become foldable at apply time, because apply-time protection is re-checked against the current config. Verified by test.assignRefsNode— latest pair getsBLOCKEDref (never citable as a boundary)filterProtectedToolMessages— latest pair excluded from a block'sdirectMessageIdsandeffectiveMessageIds(Bug 39 semantics: protected msgs must not be hidden by block coverage)buildCompressibleRanges— latest pair shows up in the protected ranges (nudge display)isAbsorbCandidate/appendAbsorbPrompts/applyAbsorb— latest-protected results are not absorbableisAbsorbCandidategains an optional third param (latest?: LatestProtected) — existing 2-arg call sites are unaffected.Config(default[]indefaultConfig) so hosts buildingConfigliterals don't break.New exports:
collectLatestProtected,isMessageLatestProtected,type LatestProtected(fromprotected.js+ index).Pre-flight
npm run typecheck: PASSnpm test: 637/637 (624 existing + 13 new intests/protected-latest.test.ts: latest-pair selection incl. glob + no-toolCallId, BLOCKED-ref assignment, range-apply exclusion vs older-pair folding, superseded-pair folding, hard-vs-soft contrast, recommendation split, absorb reject/accept)npm run build: PASSRefs ranxianglei/billion-context#637