feat(compaction): add configurable protectedTools to exempt tools from pruning#6557
Open
marlian wants to merge 1 commit intoKilo-Org:mainfrom
Open
feat(compaction): add configurable protectedTools to exempt tools from pruning#6557marlian wants to merge 1 commit intoKilo-Org:mainfrom
marlian wants to merge 1 commit intoKilo-Org:mainfrom
Conversation
…m pruning The pruner replaces old tool outputs with a placeholder to save context, but only protects the built-in 'skill' tool. Users with MCP-based skill loaders or other context-injecting tools have no way to prevent their content from being silently erased after ~40k tokens of newer output. Add compaction.protectedTools config option (string[]) that merges with the built-in default. Multiple config layers concat+dedup via mergeConfigConcatArrays, matching the existing pattern for plugin and instructions arrays. Backward-compatible: no behavior change without explicit config.
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.
Summary
compaction.protectedToolsconfig option (string[]) to specify additional tool names that should be exempt from context pruning"skill"tool remains always protected as a hardcoded defaultpluginandinstructionsarraysProblem
The pruner (
prune()incompaction.ts) replaces old tool outputs with"[Old tool result content cleared]"to save context window space. Currently, only the built-inskilltool is protected from this behavior via a hardcoded array.Users who rely on MCP-based skill/context loaders (or any tool whose output must persist throughout the session) have no way to prevent their content from being silently erased after ~40k tokens of newer tool output accumulate. This causes the model to lose critical operational context mid-session.
Solution
Make the protection list configurable:
{ "compaction": { "protectedTools": ["my_mcp_server_skill_loader", "another_context_tool"] } }Changes
src/config/config.tsprotectedTools: z.array(z.string()).optional()to compaction schemasrc/config/config.tsmergeConfigConcatArrays()to handle nestedcompaction.protectedToolsarraysrc/session/compaction.tsprotectedToolsfrom config and merge with built-in default["skill"]Design decisions
"skill"is always protected even if not explicitly listedpluginandinstructionsalready use concat + dedup inmergeConfigConcatArrays()— this adds the same logic for a nested field?? [])