Repository navigation
Claude: show the window Claude Code compacts against, and let 1M be chosen - #1221
Merged
Merged
Conversation
…hosen Claude Code 2.1.334 added an `auto` auto-compact window that compacts a 1M model such as Opus 5.5 near 400k (367k threshold) instead of 967k. Tcode sent no window for the model's default, so the CLI's `auto` took over silently while the meter and the window selector still said 1M, and choosing 1M sent nothing, so it could not be had back. - After each turn, ask `get_context_usage` and report its `maxTokens` as the session's window, so the meter counts against the window the CLI really compacts at. The session joins `auto` on its second request, which the read after that turn picks up. - A selector whose default is the model's largest window now defaults to "Auto", which sends no window and leaves the CLI to its own (its `auto`, or a size `/autocompact` saved). A size the person chooses, 1M included, is sent as `autoCompactWindow`. - The window dialog matches presets by value as well as by size, so "Auto" shows as checked and pending. The CLI's one-time `autoWindowAnnouncement` is only built for interactive sessions and first-party entrypoints, so it never reaches Tcode's headless sessions and there is nothing of it to show.
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
Claude Code 2.1.334 added an
autoauto-compact window: a 1M model such as Opus 5.5 now compacts at 367k instead of 967k. Tcode sent no window for the model's default, soautotook over silently. Meanwhile the meter and the window selector still said 1M, and choosing 1M sent nothing, so there was no way to get 1M back.on(result) TurnCompleted { usage.context_window = modelUsage.contextWindow } # 1M, the model's + send get_context_usage +on(get_context_usage answer) + context_window = maxTokens # 400k on auto + emit TokenUsageThe window dialog matches presets by value as well as by size, so a non-numeric
Autoshows as checked and as pending.The CLI's one-time
autoWindowAnnouncement, which offers the auto/keep choice, is only built for interactive sessions and first-party entrypoints (claude-desktop,claude-vscode, …). Tcode's headless sessions never receive it, so there is nothing of it to show. The window itself is what can be shown as it is.Evidence
~/.claude/projectsup to 2.1.333 happened at about 967k (preTokens964,004–979,053). On 2.1.334 two threads compacted at 367,407 and 366,968, while Tcode showed a 1M window throughout.probeagainst the installed CLI 2.1.334 with Opus 5.5 and two turns:TokenUsagewithcontext_window: 400000. The CLI joinsautoon the second request; the bare CLI shows the same (autoWindow: 400000,autoCompactThreshold: 367000).--option contextWindow=1m: the launch carriessettings={"autoCompactWindow":1000000}, and the window stays at 1M. The bare CLI with that flag reports threshold 967000 on every turn.Auto (默认)✓ /1M/自定义. Choosing 1M moves the check to 1M; choosing Auto moves it back.the_window_is_the_one_claude_code_compacts_againstuses shapes recorded from 2.1.334. Two existing tests describe what changed on purpose and were updated to it:context_window_launch_semantics: explicit1mnow sendsautoCompactWindow, andautosends nothing;manifest_descriptors_map_onto_tcode_options: the selector now leads withAuto.-D warningsand fmt are clean.Merge Danger
Door: two-way
Blast Radius: Claude sessions
autoCompactWindow: 1000000; before, it got the CLI's own default.get_context_usageread per turn: about 30 KB of JSON, answered within a few seconds.