Add context_window override so the prompt %/compaction follow it live#137
Merged
Conversation
The prompt's context-usage % and the compaction trigger derive from the model's context window, which previously could only be a hardcoded provider default — and max_tokens (the OUTPUT cap) does not change it. Add a dedicated, session-settable override. - cc_config.py: new DEFAULTS key context_window (0 = use the model default). - providers.context_window_override(config): single source that parses the override (positive int wins; 0/unset/negative/non-numeric/bool -> 0). - compaction.get_context_limit(): honors the override, kept distinct from max_tokens. Bidirectional — smaller forces earlier compaction, larger corrects a stale default. - providers.py send paths: apply the same override to the per-call output-cap window (dynamic_cap_max_tokens) so %, compaction, and the cap stay consistent. No-op when unset, so existing behavior is unchanged. - /config context_window=<N>: warns when it exceeds the model's real window (disables compaction -> API may reject oversized prompts) and notes it takes effect on the next prompt (no restart). Read live each prompt, so changing model or context_window updates the % with no restart. Tests cover parsing, both-direction overrides, and that max_tokens is never read as the context window. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
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.
The prompt's context-usage % and the compaction trigger derive from the model's context window, which previously could only be a hardcoded provider default — and max_tokens (the OUTPUT cap) does not change it. Add a dedicated, session-settable override.
Read live each prompt, so changing model or context_window updates the % with no restart. Tests cover parsing, both-direction overrides, and that max_tokens is never read as the context window.