Skip to content

Claude: show the window Claude Code compacts against, and let 1M be chosen - #1221

Merged
Tryanks merged 1 commit into
mainfrom
claude/claude-auto-compact-window
Dec 2, 2026
Merged

Tryanks merged 1 commit into
mainfrom
claude/claude-auto-compact-window

Conversation

@Tryanks

@Tryanks Tryanks commented Dec 2, 2026

Copy link
Copy Markdown
Owner

Summary

Claude Code 2.1.334 added an auto auto-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, so auto took 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 TokenUsage
 Opus 5.5 / any model whose default window is its largest
-  [1M (default)]            → sends nothing (CLI now runs auto)
+  [Auto (default)]          → sends nothing: the CLI's own (auto, or a size /autocompact saved)
+  [1M]                      → --settings {"autoCompactWindow":1000000}
   [Custom]                  → --settings {"autoCompactWindow":N}

The window dialog matches presets by value as well as by size, so a non-numeric Auto shows 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

  • Before: every Claude Code auto-compaction in ~/.claude/projects up to 2.1.333 happened at about 967k (preTokens 964,004–979,053). On 2.1.334 two threads compacted at 367,407 and 366,968, while Tcode showed a 1M window throughout.
  • After, from probe against the installed CLI 2.1.334 with Opus 5.5 and two turns:
    • Default: turn 1 shows 1M, and after turn 2 a TokenUsage with context_window: 400000. The CLI joins auto on the second request; the bare CLI shows the same (autoWindow: 400000, autoCompactThreshold: 367000).
    • --option contextWindow=1m: the launch carries settings={"autoCompactWindow":1000000}, and the window stays at 1M. The bare CLI with that flag reports threshold 967000 on every turn.
  • Running app (throwaway profile, Opus 5.5 draft): the dialog lists Auto (默认) ✓ / 1M / 自定义. Choosing 1M moves the check to 1M; choosing Auto moves it back.
  • Tests: new the_window_is_the_one_claude_code_compacts_against uses shapes recorded from 2.1.334. Two existing tests describe what changed on purpose and were updated to it:
    • context_window_launch_semantics: explicit 1m now sends autoCompactWindow, and auto sends nothing;
    • manifest_descriptors_map_onto_tcode_options: the selector now leads with Auto.
  • Checks: workspace nextest 1553 passed, 7 skipped; clippy -D warnings and fmt are clean.

Merge Danger

Door: two-way

Blast Radius: Claude sessions

  • A thread that had explicitly chosen 1M now launches with autoCompactWindow: 1000000; before, it got the CLI's own default.
  • Moving between Auto and an explicit size takes a process restart, as other window changes already do.
  • One extra get_context_usage read per turn: about 30 KB of JSON, answered within a few seconds.

…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.
@Tryanks
Tryanks merged commit fc6736b into main Dec 2, 2026
25 of 26 checks passed
@Tryanks
Tryanks deleted the claude/claude-auto-compact-window branch December 2, 2026 11:48
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant