Claude Code: Long-Session Stability & VS Code Plan Preview
Claude Code 2.1.47 is a wide-ranging stability release that addresses memory growth problems in long-running sessions through multiple targeted fixes, including the elimination of O(n²) message accumulation in agent progress updates and proper release of API stream buffers and skill state after use. The release also delivers a substantially improved VS Code plan preview experience, a new last_assistant_message field in hook inputs, and background agent lifecycle enhancements. Dozens of Windows compatibility fixes and session management improvements round out the release.
Sources & Mentions
5 external resources covering this update
Memory Management Overhaul for Long Sessions
Long-running Claude Code sessions have historically suffered from steady RSS growth as objects accumulated in memory without being released. Version 2.1.47 addresses this through several coordinated fixes:
O(n²) message accumulation eliminated. During long agent sessions, progress update messages were being accumulated using an algorithm that scaled quadratically with session length. This has been replaced with a linear approach, dramatically reducing memory pressure in sessions involving many agent interactions.
Stream buffers and state now released after use. API stream buffers, agent context objects, and skill state are now properly freed once a task completes, rather than being held for the duration of the session. Agent task message history is also trimmed after tasks finish.
WASM memory issues fixed. Two WASM-related memory leaks — one in the tree-sitter parser and one in Yoga's layout engine — that cause linear memory to grow indefinitely during long sessions have been resolved. (Note: these fixes also appear in 2.1.49, suggesting backport or staged rollout.)
Together, these changes make Claude Code substantially more viable for long autonomous runs where RSS growth was previously a limiting factor.
VS Code Plan Preview Improvements
The plan preview panel in VS Code has been redesigned for a more collaborative workflow:
- The preview now auto-updates as Claude iterates, so developers always see the latest version of the plan as it evolves
- The commenting interface is locked until the plan is ready for review, preventing premature annotations on intermediate drafts
- When a reviewer rejects a plan, the preview remains open so Claude can revise in place rather than starting from a blank state
These changes bring the VS Code plan preview closer to a proper review-and-iterate workflow, rather than a one-shot view.
Background Agent Lifecycle Control
The release formalizes background agent lifecycle management. The Ctrl+F keybinding (which first appeared in 2.1.49's release notes but was introduced here) kills all background agents, replacing the previous behavior of double-pressing ESC. Background agents now continue running when ESC is pressed to cancel the main thread, giving developers independent control over background work.
Hook Improvements: last_assistant_message
The Stop and SubagentStop hook events now include a last_assistant_message field in their input, providing the final assistant response text. This allows hook consumers to react to or log the assistant's last output without parsing raw transcript files.
Windows Compatibility Fixes
This release contains the most comprehensive set of Windows fixes in recent memory:
- Terminal rendering bugs caused by
os.EOL(\r\n) line endings — including incorrect line counts and misaligned text — have been resolved - Bold and colored markdown text no longer shifts to wrong characters on Windows
- Bash tool output was being silently discarded in MSYS2/Cygwin shells; this is now fixed
- CWD tracking temp files were accumulating indefinitely; they are now cleaned up
- Hooks (
PreToolUse,PostToolUse) were silently failing because they invokedcmd.exerather than Git Bash; fixed - The Right Alt key was leaving visible
[25~escape sequences in the input field; fixed
Session and Navigation Fixes
- Custom session titles set via
/renamewere being lost after context compaction; they now persist - The plan mode setting is no longer lost after compaction — sessions no longer unexpectedly switch from planning to implementation
- Sessions with large first prompts (>16KB) were disappearing from the
/resumelist; fixed - The initial session count in the resume picker has been increased from 10 to 50
- The
/renamecommand now updates the terminal tab title by default - Config backup files have been moved from the home directory root to
~/.claude/backups/