feat: model-aware safety buffer for context compaction (closes #2)#5
Merged
Conversation
Replace flat SAFETY_BUFFER_TOKENS (13,000) with tiered safety_buffer_for_window() that scales proportionally: >= 200K -> 8,000 | >= 32K -> 4,000 | < 32K -> 2,000 Replace flat DEFAULT_COMPACT_RATIO (0.75) with tiered compact_ratio_for_window(): >= 100K -> 0.85 (less aggressive) | < 100K -> 0.75 compact_trigger_threshold now takes &ModelSpec instead of raw capacity, computing usable_window() internally. Closes #2
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.
What
Implements #2 — replaces the flat compaction safety buffer and ratio with tiered, model-aware functions.
Changes
Safety buffer
SAFETY_BUFFER_TOKENS = 13,000safety_buffer_for_window(context_window) -> usize:Compaction ratio
DEFAULT_COMPACT_RATIO = 0.75compact_ratio_for_window(context_window) -> f64:API change
compact_trigger_threshold(&ModelSpec)— now model-aware, computes usable_window() internallyImpact
Verification