fix(context): avoid 100 percent threshold at minimum context length#24076
Open
soynchux wants to merge 1 commit into
Open
fix(context): avoid 100 percent threshold at minimum context length#24076soynchux wants to merge 1 commit into
soynchux wants to merge 1 commit into
Conversation
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
Fix context compression threshold calculation for minimum-context models.
Previously,
ContextCompressoralways applied the 64K floor directly tothreshold_tokens. On models with a 64K context window, that could raise theeffective trigger to 100% of the window, so auto-compression would not fire
until the context was already exhausted.
This change keeps the historical 64K floor for larger context windows, but
falls back to the configured percentage when the floor would otherwise consume
the entire minimum context window.
Closes #14690.
What changed
_compute_threshold_tokens()helper inContextCompressor__init__()andupdate_model()Why this is safe
Tests
uv run --group dev pytest tests/agent/test_context_compressor.py -k "threshold or minimum_context_window or update_model_preserves" -n 0uv run --group dev pytest tests/run_agent/test_compression_feasibility.py tests/run_agent/test_compressor_fallback_update.py -k "threshold or exact_threshold_boundary_no_warning or just_below_threshold_auto_corrects" -n 0