news

Claude Code v2.1.50: Worktree Hooks, Agent Memory Overhaul, Opus 4.6 Gets 1M Context

AI Tools Hub
#Claude Code #Anthropic #release notes #bug fixes #memory management #agents

Anthropic ships Claude Code v2.1.50 with WorktreeCreate/WorktreeRemove hook events, declarative worktree isolation in agent definitions, a fix for session data loss on SSH disconnect, a native module compatibility fix for older glibc Linux systems, an avalanche of memory leak fixes targeting long-running sessions, and Opus 4.6 fast mode now supporting the full 1M context window.

Anthropic published Claude Code v2.1.50 to npm on February 20, 2026 (UTC), approximately 24 hours after v2.1.49. The release ships roughly 26 changes, with memory management improvements dominating the changelog: at least nine separate memory leaks across long-running sessions, agent teams, LSP servers, and shell execution are addressed in a single release. The update also introduces new worktree lifecycle hooks, a declarative isolation option in agent definitions, a Linux compatibility fix for older enterprise distributions, and 1M context support for Opus 4.6 fast mode.

Worktree Lifecycle Hooks

Two new hook events — WorktreeCreate and WorktreeRemove — fire when agent worktree isolation creates or removes a git worktree. This gives teams a clean integration point for custom VCS setup and teardown scripts that need to stay aligned with agent isolation boundaries. CI systems, monorepo setups with custom branch conventions, or deployments that need to register worktrees with external tooling all stand to benefit.

Declarative Worktree Isolation in Agent Definitions

Agent definition files can now include isolation: worktree to declare that the agent should run inside an isolated git worktree. Previously, achieving isolation required external configuration or wrapper scripts. The declarative form keeps isolation policy colocated with the agent definition itself, making it easier to audit and reproduce.

SSH Disconnect No Longer Causes Session Data Loss

When an SSH connection drops, Claude Code’s graceful shutdown sequence now flushes session data before running hooks and analytics. Previously, hooks and analytics could race ahead and exit before session data was written, silently discarding session history. Users on remote development setups over SSH will find their session state preserved through unexpected disconnections.

A startup path resolution inconsistency caused sessions to become invisible in the resume picker when the working directory included symlinks. The session storage path was resolved at different points during initialization, producing mismatched keys. This is fixed in v2.1.50.

Linux: Native Module Fix for Old glibc Systems

Native modules failed to load on Linux systems with glibc versions older than 2.30 — a threshold that excludes RHEL 8 and comparable enterprise distributions. This is now fixed, broadening Claude Code’s compatibility with the kind of locked-down Linux environments common in regulated industries.

claude agents Command

A new claude agents CLI command lists all configured agents. Previously, there was no direct way to inspect registered agents from the terminal; users had to navigate config files manually. This is a small ergonomic addition but meaningful for teams managing more than a handful of agent definitions.

CLAUDE_CODE_SIMPLE Gets a Deeper Simplification

The CLAUDE_CODE_SIMPLE environment variable now strips far more than before. In addition to the previous reductions, v2.1.50 disables MCP tools, attachments, hooks, CLAUDE.md file loading, skills, session memory, custom agents, and CLAUDE.md token counting. The result is a fully minimal execution environment with drastically reduced token overhead — well-suited for CI pipelines or cost-controlled scripted use cases.

Startup Performance: Deferred Yoga WASM and UI Imports in Headless Mode

The -p (non-interactive) flag now defers Yoga WASM and UI component imports until they are actually needed. Since headless mode never renders a terminal UI, these imports previously ran unconditionally at startup and added avoidable latency. Cold start time for scripted and CI usage is reduced.

Opus 4.6 Fast Mode Now Supports 1M Context

Opus 4.6 in fast mode gains the full 1M token context window in v2.1.50. Sonnet 4.6 received 1M context support in v2.1.49; this extends the same capability to the Opus tier.

Additionally, a new CLAUDE_CODE_DISABLE_1M_CONTEXT environment variable allows operators to explicitly opt out of the 1M context window. This is useful for cost management or environments where context length needs to be bounded by policy rather than trust.

VS Code: /extra-usage Command

The /extra-usage command is now available inside VS Code sessions. It was previously terminal-only. VS Code extension users can now check additional token usage information without switching to a terminal.

Memory Management: Nine Fixes Across the Stack

v2.1.50 addresses a cluster of memory leaks that compounded during long sessions. Independently:

  • Agent team task objects were never removed from AppState after completion, causing unbounded growth in sessions running many tasks in parallel.
  • LSP diagnostic data accumulated without bound after delivery — each diagnostic was kept in memory indefinitely rather than being cleaned up post-delivery.
  • Completed task output (TaskOutput) was retained in memory after tasks finished.
  • TaskOutput “recent lines” buffer continued holding data after a cleanup pass.
  • CircularBuffer was retaining cleared items in its backing array rather than releasing them.
  • Shell command execution held ChildProcess and AbortController references after commands completed.
  • Internal caches are now cleared after compaction runs, rather than accumulating across the session lifecycle.
  • File history snapshots are now capped, preventing unbounded memory growth from snapshot accumulation over many edits.
  • Large tool results are cleared from memory after processing rather than being retained for potential re-inspection.

The cumulative effect is significant: long-running sessions that previously required periodic restarts due to memory pressure should exhibit substantially more stable memory profiles.

Other Fixes

  • /mcp reconnect CLI freeze: Passing a non-existent server name no longer hangs the CLI.
  • MCP tool discovery with launch-argument prompts: MCP tools were not discovered when tool search was enabled and a prompt was provided as a launch argument. Fixed.
  • Prompt suggestion cache: An additional regression fix continues work started in v2.1.49 to restore expected cache hit rates.
  • LSP server startupTimeout: Configuration support for startupTimeout on LSP servers is now available.

Version Details

  • Version: 2.1.50
  • Published: February 20, 2026 (UTC) / February 21, 2026 (JST)
  • npm: @anthropic-ai/claude-code
  • Install / upgrade: npm install -g @anthropic-ai/claude-code

Release Cadence Note

v2.1.50 continues Anthropic’s recent pattern of daily patch releases. The concentration of memory fixes suggests internal tooling or testing revealed a broad class of object lifecycle issues across agent, LSP, and shell subsystems simultaneously. For teams running production agentic workflows, upgrading is recommended.

Related Articles

Popular Articles

Latest Articles

0 tools selected