- 2.1.335 Next
- 2.1.334 This release
- 2.1.333 Previous
Claude Code 2.1.334: auto-compact drops to 400K, worktrees stop losing commits
2.1.334 extends the 400K auto-compact threshold on 1M-context models to -p and SDK sessions, and fixes two worktree bugs that could start on the wrong branch or lose an unpushed commit on resume.
2.1.335 has shipped since, on December 3. Read 2.1.335
Claude Code 2.1.334, released December 1, 2026, ships around thirty additions, roughly twenty behavior changes, 34 improvements and 201 bug fixes. Two changes deserve your attention if you run long sessions through -p or the SDK, or juggle several worktrees: the default auto-compact setting now sits near 400K tokens on most 1M-context models, -p and SDK sessions included, and two separate worktree bugs are fixed, one that could start a worktree on the wrong branch, another that could drop an unpushed commit on resume. Everything else is a pile of VS Code, Claude Code on the web and Claude Tag polish, plus a handful of reliability fixes touching MCP servers and Code Mode.
Auto-compact now drops to 400K, including -p and the SDK
2.1.334 moves auto-compact's default auto setting to near 400K tokens on most current 1M-context models, and the changelog notes that this covers -p and SDK-driven sessions too. The auto-compact documentation lists the models involved: Sonnet 5 and later, Haiku 5.5, a recent release this site doesn't yet list as open to every plan, Opus 4.7 and later, the Fable models. Its table of sessions that run past 400K by default says that before 2.1.334 a session ran at 1M, and that some still keep 1M on the new version: Desktop and cloud scheduled tasks, sessions in a self-hosted environment, and a conversation resumed when it's already past 400K, until it next compacts. The rollout is gradual; it's already on with third-party providers or with telemetry turned off.
In practice, a -p session or an SDK pipeline that used to accumulate context up to 1M tokens before compacting now compacts much sooner. The docs note that on auto at 400K, compaction actually kicks in around 367K tokens, with used_percentage showing roughly 37% because it's measured against the full 1M window. Shorter requests more often, so a cheaper bill for long sessions, but also less raw context between compactions for a pipeline that was counting on the full window.
To keep the full 1M despite this change, run /autocompact 1M in the session, or set CLAUDE_CODE_AUTO_COMPACT_WINDOW=1000000 in the environment that launches the process, the documented path for scripts and cloud environments. 2.1.334 also adds an Auto-compact window row to /config to see and change the size /autocompact sets. If you run -p sessions or SDK agents in production and never set /autocompact explicitly, check that this new threshold doesn't break a pipeline assumption about how much context stays available before compaction.
Two worktree bugs fixed: wrong starting branch, lost commits on resume
Worktrees isolate parallel sessions in separate checkouts, each on its own branch, so two Claude Code sessions don't step on each other. 2.1.334 fixes two distinct bugs that undermined that isolation.
The first: a worktree could start from the wrong branch or the wrong local HEAD after Claude moved into another repository, or with --worktree in some bare repositories whose default branch isn't main. A worktree meant to branch from your default could end up somewhere else without anything flagging it.
The second is more serious: resuming an unchanged worktree could drop an unpushed commit that only its branch still held. The docs on resuming a worktree session note that Claude Code returns a resumed session to its worktree for --resume and --continue as well as for the SDK, and first checks that the worktree is still a checkout separate from the main one. The automatic sweep leaves a worktree holding unpushed commits in place, and reusing an existing worktree only resets it when it has no commits of its own or its work is already merged; this bug broke that guarantee in one specific case.
If you run parallel worktrees with commits that sit locally for a while before being pushed, say to get them reviewed first, check that no worktree branch is missing a commit you thought you'd kept. 2.1.334 fixes the bug that caused it; it doesn't restore a commit already lost on an earlier version.
What else matters
Several reliability fixes close real pain points. MCP servers that request a zero retry delay and keep closing their event stream were causing high CPU usage and memory that grew on every reconnect; both are fixed. Code Mode, which lets Claude write scripts instead of chaining tool calls one by one, gets several reliability fixes: subagents that crashed with "Agent stalled" and lost their command after running more than ten minutes, the terminal freezing while checking an rm touching many files, and a script's tool calls being wrongly counted toward context size, which triggered early compaction.
Requests sent with thinking turned off to a model that requires it used to fail outright; Claude Code now resends them without that setting, at the cost of thinking you meant to disable. /model gets a search box once the list passes 25 models, handy on accounts exposing many through a gateway. Grep now applies fewer ignore files in some sessions, which can surface files it used to hide: a search that came back empty might now find something, for better or worse depending on what you expected that filtering to do.
On the infrastructure side, self-hosted runners now cap a call that never finishes at 60 seconds by default, where it used to hang the runner or orchestrator indefinitely. VS Code absorbs most of the remaining volume: accessibility, keyboard focus, the new-look panel, plus a batch of fixes for Claude Code on the web and Claude Tag that only matter to teams using those surfaces day to day.
This digest is written by a Claude routine from the official Claude Code changelog, then checked by a script and a full build before it goes live. How that works: Claude Routines, the complete guide. Claude Hub is published by Pierre Rondeau.