feat(compression): add absolute token threshold via compression.threshold_tokens - #24279
DanielMaly wants to merge 1 commit into
Conversation
|
Thanks for the absolute-threshold proposal. Current main still derives compression solely from Problems
Suggested changes
Automated hermes-sweeper review. |
a4ae967 to
a8b033e
Compare
Rework addressing sweeper feedbackThis commit replaces the previous implementation with a clean rework that addresses all points from the automated review: Changes from the review feedback
Files changed
|
…hold_tokens Add compression.threshold_tokens config option that sets an absolute token cap for auto-compaction. When configured alongside the existing ratio-based threshold, the effective trigger point is the lower of the two, so compression never fires later than the user's preferred token count regardless of which model is active. This solves the problem where switching between models with different context windows (e.g. 1M → 400K) shifts the absolute trigger point, causing premature or delayed compression. Rework from PR NousResearch#24279 addressing sweeper feedback: - The cap is now a first-class compressor configuration value (threshold_tokens_cap parameter on ContextCompressor.__init__), not a post-construction patch on the live instance. - Applied in both __init__ and update_model() so it survives model switches and fallback activations (the old approach was undone by update_model() restoring _configured_threshold_percent). - Clamped to the model's context length so a cap above the window is a no-op (ratio-based threshold wins). - Works with max_tokens output-token reservations. - Added 9 tests covering cap-vs-ratio selection, model switch survival, context-length clamping, max_tokens interaction, and invalid values. - Updated user-facing configuration docs. - Removed unrelated background-review/curator/Honcho changes (main already contains background-review memory isolation in 973f27e). Config example: compression: threshold: 0.50 threshold_tokens: 200000 # never compress later than 200K tokens
a8b033e to
9358033
Compare
…hold_tokens Add compression.threshold_tokens config option that sets an absolute token cap for auto-compaction. When configured alongside the existing ratio-based threshold, the effective trigger point is the lower of the two, so compression never fires later than the user's preferred token count regardless of which model is active. This solves the problem where switching between models with different context windows (e.g. 1M → 400K) shifts the absolute trigger point, causing premature or delayed compression. Rework from PR #24279 addressing sweeper feedback: - The cap is now a first-class compressor configuration value (threshold_tokens_cap parameter on ContextCompressor.__init__), not a post-construction patch on the live instance. - Applied in both __init__ and update_model() so it survives model switches and fallback activations (the old approach was undone by update_model() restoring _configured_threshold_percent). - Clamped to the model's context length so a cap above the window is a no-op (ratio-based threshold wins). - Works with max_tokens output-token reservations. - Added 9 tests covering cap-vs-ratio selection, model switch survival, context-length clamping, max_tokens interaction, and invalid values. - Updated user-facing configuration docs. - Removed unrelated background-review/curator/Honcho changes (main already contains background-review memory isolation in 973f27e). Config example: compression: threshold: 0.50 threshold_tokens: 200000 # never compress later than 200K tokens
…tokens Follow-up for salvaged #24279: - cli-config.yaml.example: document compression.threshold_tokens (commented-out, default null = disabled) - contributors/emails: map maly.dan@gmail.com -> DanielMaly - tests: should_compress() fires at the absolute cap below the pct threshold (first-fires-wins); DEFAULT_CONFIG ships None and 0/None are behavior-neutral incl. across update_model(); the small-context pct floor is unaffected by the cap and re-derives correctly on model switch
…hold_tokens Add compression.threshold_tokens config option that sets an absolute token cap for auto-compaction. When configured alongside the existing ratio-based threshold, the effective trigger point is the lower of the two, so compression never fires later than the user's preferred token count regardless of which model is active. This solves the problem where switching between models with different context windows (e.g. 1M → 400K) shifts the absolute trigger point, causing premature or delayed compression. Rework from PR #24279 addressing sweeper feedback: - The cap is now a first-class compressor configuration value (threshold_tokens_cap parameter on ContextCompressor.__init__), not a post-construction patch on the live instance. - Applied in both __init__ and update_model() so it survives model switches and fallback activations (the old approach was undone by update_model() restoring _configured_threshold_percent). - Clamped to the model's context length so a cap above the window is a no-op (ratio-based threshold wins). - Works with max_tokens output-token reservations. - Added 9 tests covering cap-vs-ratio selection, model switch survival, context-length clamping, max_tokens interaction, and invalid values. - Updated user-facing configuration docs. - Removed unrelated background-review/curator/Honcho changes (main already contains background-review memory isolation in 973f27e). Config example: compression: threshold: 0.50 threshold_tokens: 200000 # never compress later than 200K tokens
…tokens Follow-up for salvaged #24279: - cli-config.yaml.example: document compression.threshold_tokens (commented-out, default null = disabled) - contributors/emails: map maly.dan@gmail.com -> DanielMaly - tests: should_compress() fires at the absolute cap below the pct threshold (first-fires-wins); DEFAULT_CONFIG ships None and 0/None are behavior-neutral incl. across update_model(); the small-context pct floor is unaffected by the cap and re-derives correctly on model switch
…hold_tokens Add compression.threshold_tokens config option that sets an absolute token cap for auto-compaction. When configured alongside the existing ratio-based threshold, the effective trigger point is the lower of the two, so compression never fires later than the user's preferred token count regardless of which model is active. This solves the problem where switching between models with different context windows (e.g. 1M → 400K) shifts the absolute trigger point, causing premature or delayed compression. Rework from PR NousResearch#24279 addressing sweeper feedback: - The cap is now a first-class compressor configuration value (threshold_tokens_cap parameter on ContextCompressor.__init__), not a post-construction patch on the live instance. - Applied in both __init__ and update_model() so it survives model switches and fallback activations (the old approach was undone by update_model() restoring _configured_threshold_percent). - Clamped to the model's context length so a cap above the window is a no-op (ratio-based threshold wins). - Works with max_tokens output-token reservations. - Added 9 tests covering cap-vs-ratio selection, model switch survival, context-length clamping, max_tokens interaction, and invalid values. - Updated user-facing configuration docs. - Removed unrelated background-review/curator/Honcho changes (main already contains background-review memory isolation in ba371c6). Config example: compression: threshold: 0.50 threshold_tokens: 200000 # never compress later than 200K tokens
…tokens Follow-up for salvaged NousResearch#24279: - cli-config.yaml.example: document compression.threshold_tokens (commented-out, default null = disabled) - contributors/emails: map maly.dan@gmail.com -> DanielMaly - tests: should_compress() fires at the absolute cap below the pct threshold (first-fires-wins); DEFAULT_CONFIG ships None and 0/None are behavior-neutral incl. across update_model(); the small-context pct floor is unaffected by the cap and re-derives correctly on model switch
…hold_tokens Add compression.threshold_tokens config option that sets an absolute token cap for auto-compaction. When configured alongside the existing ratio-based threshold, the effective trigger point is the lower of the two, so compression never fires later than the user's preferred token count regardless of which model is active. This solves the problem where switching between models with different context windows (e.g. 1M → 400K) shifts the absolute trigger point, causing premature or delayed compression. Rework from PR NousResearch#24279 addressing sweeper feedback: - The cap is now a first-class compressor configuration value (threshold_tokens_cap parameter on ContextCompressor.__init__), not a post-construction patch on the live instance. - Applied in both __init__ and update_model() so it survives model switches and fallback activations (the old approach was undone by update_model() restoring _configured_threshold_percent). - Clamped to the model's context length so a cap above the window is a no-op (ratio-based threshold wins). - Works with max_tokens output-token reservations. - Added 9 tests covering cap-vs-ratio selection, model switch survival, context-length clamping, max_tokens interaction, and invalid values. - Updated user-facing configuration docs. - Removed unrelated background-review/curator/Honcho changes (main already contains background-review memory isolation in 973f27e). Config example: compression: threshold: 0.50 threshold_tokens: 200000 # never compress later than 200K tokens
…tokens Follow-up for salvaged NousResearch#24279: - cli-config.yaml.example: document compression.threshold_tokens (commented-out, default null = disabled) - contributors/emails: map maly.dan@gmail.com -> DanielMaly - tests: should_compress() fires at the absolute cap below the pct threshold (first-fires-wins); DEFAULT_CONFIG ships None and 0/None are behavior-neutral incl. across update_model(); the small-context pct floor is unaffected by the cap and re-derives correctly on model switch
…hold_tokens Add compression.threshold_tokens config option that sets an absolute token cap for auto-compaction. When configured alongside the existing ratio-based threshold, the effective trigger point is the lower of the two, so compression never fires later than the user's preferred token count regardless of which model is active. This solves the problem where switching between models with different context windows (e.g. 1M → 400K) shifts the absolute trigger point, causing premature or delayed compression. Rework from PR NousResearch#24279 addressing sweeper feedback: - The cap is now a first-class compressor configuration value (threshold_tokens_cap parameter on ContextCompressor.__init__), not a post-construction patch on the live instance. - Applied in both __init__ and update_model() so it survives model switches and fallback activations (the old approach was undone by update_model() restoring _configured_threshold_percent). - Clamped to the model's context length so a cap above the window is a no-op (ratio-based threshold wins). - Works with max_tokens output-token reservations. - Added 9 tests covering cap-vs-ratio selection, model switch survival, context-length clamping, max_tokens interaction, and invalid values. - Updated user-facing configuration docs. - Removed unrelated background-review/curator/Honcho changes (main already contains background-review memory isolation in 0422ec6). Config example: compression: threshold: 0.50 threshold_tokens: 200000 # never compress later than 200K tokens
…tokens Follow-up for salvaged NousResearch#24279: - cli-config.yaml.example: document compression.threshold_tokens (commented-out, default null = disabled) - contributors/emails: map maly.dan@gmail.com -> DanielMaly - tests: should_compress() fires at the absolute cap below the pct threshold (first-fires-wins); DEFAULT_CONFIG ships None and 0/None are behavior-neutral incl. across update_model(); the small-context pct floor is unaffected by the cap and re-derives correctly on model switch
…hold_tokens Add compression.threshold_tokens config option that sets an absolute token cap for auto-compaction. When configured alongside the existing ratio-based threshold, the effective trigger point is the lower of the two, so compression never fires later than the user's preferred token count regardless of which model is active. This solves the problem where switching between models with different context windows (e.g. 1M → 400K) shifts the absolute trigger point, causing premature or delayed compression. Rework from PR NousResearch#24279 addressing sweeper feedback: - The cap is now a first-class compressor configuration value (threshold_tokens_cap parameter on ContextCompressor.__init__), not a post-construction patch on the live instance. - Applied in both __init__ and update_model() so it survives model switches and fallback activations (the old approach was undone by update_model() restoring _configured_threshold_percent). - Clamped to the model's context length so a cap above the window is a no-op (ratio-based threshold wins). - Works with max_tokens output-token reservations. - Added 9 tests covering cap-vs-ratio selection, model switch survival, context-length clamping, max_tokens interaction, and invalid values. - Updated user-facing configuration docs. - Removed unrelated background-review/curator/Honcho changes (main already contains background-review memory isolation in 973f27e). Config example: compression: threshold: 0.50 threshold_tokens: 200000 # never compress later than 200K tokens
…tokens Follow-up for salvaged NousResearch#24279: - cli-config.yaml.example: document compression.threshold_tokens (commented-out, default null = disabled) - contributors/emails: map maly.dan@gmail.com -> DanielMaly - tests: should_compress() fires at the absolute cap below the pct threshold (first-fires-wins); DEFAULT_CONFIG ships None and 0/None are behavior-neutral incl. across update_model(); the small-context pct floor is unaffected by the cap and re-derives correctly on model switch
Reopened from #22762 (auto-closed during fork sync).
Adds a new
compression.threshold_tokensconfig option that triggers compression when the conversation exceeds an absolute token count, regardless of context window utilization.This is useful for:
The threshold is checked alongside the existing utilization-based compression trigger — whichever fires first wins.