feat(compression): configurable protect_first_n/protect_last_n turns (reopen #756) - #27090
Closed
Master-Rensei wants to merge 1 commit into
Closed
feat(compression): configurable protect_first_n/protect_last_n turns (reopen #756)#27090Master-Rensei wants to merge 1 commit into
Master-Rensei wants to merge 1 commit into
Conversation
Add protect_first_n and protect_last_n to the compression config section in config.yaml, allowing users to control how many initial and recent turns are preserved during context compression. - Default values: protect_first_n=3, protect_last_n=4 (no behavior change) - Values clamped to 0-12 range (inspired by openclaw recentTurnsPreserve) - Config version bumped to 6 for migration - Also improved run_agent.py to read compression config from config.yaml (previously only read from env vars) Related: #525 (microcompact)
Collaborator
|
Note: protect_first_n was already made configurable in #25447 (merged). This PR may still add protect_last_n configurability and config version bump. |
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
Reopening closed PR #756 (not merged). Adds
protect_first_nandprotect_last_nto the compression config inconfig.yaml, allowing users to control how many initial and recent turns are preserved during context compression.Changes
hermes_cli/config.py: Addedprotect_first_n: 3andprotect_last_n: 4toDEFAULT_CONFIG.compression. Bumped config version to 6.run_agent.py: Reads protection values from config.yaml (with 0-12 clamping). Also improved to readthresholdandsummary_modelfrom config.yaml rather than only env vars.tests/test_compression_config.py: 8 tests covering defaults, config version, ContextCompressor param passing, and clamping logic.Config Example
Inspired by openclaw's
recentTurnsPreserveconfig (clamped 0-12, default 3) from v2026.3.7.Related: #525, closes #756