Packages
Claude Agent SDK 0.3.334: Breaking MCP Delivery, 400K Auto-Compact, and TypeScript /core Bundling
Published December 2, 2026 on npm and GitHub, @anthropic-ai/claude-agent-sdk 0.3.334 reaches parity with Claude Code v2.1.334 while capping a series of breaking MCP, hook, and session-compaction changes. Here is what TypeScript and Node/Bun teams must update before upgrading.
8 min read
Claude Agent SDK 0.3.334: Breaking MCP Delivery, 400K Auto-Compact, and TypeScript /core Bundling
Executive Summary
On December 2, 2026, Anthropic published @anthropic-ai/claude-agent-sdk v0.3.334 to npm and GitHub, bringing the TypeScript agent runtime to parity with Claude Code v2.1.334. Requiring TypeScript 5.0+ and Node.js 18.14+ (or Bun), the SDK embeds the native Claude Code binary loop via platform-specific optional dependencies, exposing query(), startup(), prewarm(), hooks, subagents, and in-process Model Context Protocol (MCP) servers directly inside application processes.
Across the v0.3.325–v0.3.334 release train (mid-November through December 2, 2026), Anthropic shipped several high-impact runtime and breaking changes: mcpServersDelivery now defaults to 'initialize' instead of 'argv' (v0.3.333), SYSTEM_PROMPT_DYNAMIC_BOUNDARY cache breakpoints now work across Amazon Bedrock, Google Cloud Agent Platform, Foundry, and API gateways (v0.3.334), auto-compaction defaults on 1M-context models shifted toward 400K tokens (v0.3.334), and Query.setPermissionMode() changed its return contract from Promise<void> to { mode } (v0.3.332). For teams running @anthropic-ai/claude-agent-sdk in CI, backend workers, or bun build --compile binaries, upgrading safely requires auditing CLI parity, hook array types, and optional binary packaging.
Adoption Telemetry & Version Changelog
As of December 2, 2026, @anthropic-ai/claude-agent-sdk on npm records 15,830,193 weekly downloads, 2,364 dependent packages, 354 published versions, and 0 runtime dependencies in its root bundle. On GitHub, the TypeScript repository holds 1.9k stars and 260 forks under Anthropic's Commercial Terms of Service (LICENSE.md).
Independent registry analysis published November 28, 2026 by Blocksize AI Workshop (tracking api.npmjs.org monthly sums) shows how steep the TypeScript adoption curve has been: @anthropic-ai/claude-agent-sdk climbed from 1.4 million monthly npm downloads in November 2025 to 61.6 million in October 2026, and reached 83 million downloads in the 30 days ending November 26, 2026. Over the same period, its Python sibling claude-agent-sdk on PyPI (v0.2.189 as of November 24, 2026, MIT license) reached 40 million 30-day downloads, according to Blocksize's pypistats.org tally. Downstream protocol bridges are already tracking the shift—for example, agentclientprotocol/claude-agent-acp v0.114.0 (December 1, 2026) updated to @anthropic-ai/claude-agent-sdk 0.3.333 alongside replay-cursor session reading.
Key Milestones Across v0.3.325 to v0.3.334
The GitHub Releases changelog documents ten rapid releases culminating in v0.3.334:
- v0.3.334 (December 2, 2026 — Claude Code v2.1.334 parity):
- Cache breakpoint fix: Fixed
SYSTEM_PROMPT_DYNAMIC_BOUNDARYbeing ignored on Amazon Bedrock, Google Cloud Agent Platform, Foundry, API gateways, or when experimental betas are disabled—the static text above the boundary now properly receives a prompt-cache breakpoint without altering prompt text. - Auto-compaction window change: Shifted per-model
auto-compactdefaults to near400Ktokens on most current 1M-context models (rolling out on first-party and live on third-party providers); setautoCompactWindowundermodelSettingsif you need to retain the full 1M window. - Browser WebSocket & in-process MCP fixes: Fixed the browser SDK's WebSocket transport leaving behind a pending write and open socket if aborted pre-connect, and resolved an early-termination bug when an in-process MCP server sent a request carrying the same JSON-RPC
idas an active tool call. - Observability fields: Added
duration_msto shelltask_notificationevents,old_cell_typetoNotebookEditreplace/delete results,tool_use_resulton subagentPushNotificationand emptyWebFetchmessages, andconsumer_terms_review_in_terminal,consumer_terms_accept_on_web, andresume_target_not_foundtostartup_failure_reason.
- Cache breakpoint fix: Fixed
- v0.3.333 (December 1, 2026 — Claude Code v2.1.333 parity):
- Breaking
mcpServersDeliverychange: DefaultedmcpServersDeliveryto'initialize', sending MCP server configs inside the JSONinitializehandshake rather than on the spawned CLI'sargvcommand line (preventing command-line leakage and length limits). Apps launching an external Claude Code binary older than2.1.326with stdio, HTTP, or SSEmcpServersmust upgrade the binary or passmcpServersDelivery: 'argv'. - Transcript & subagent fixes: Fixed
getSubagentMessages()dropping parallel tool calls/results and fixedgetSessionMessageshanging on>2 GiBtranscripts (alongside Bun fixes forgetSubagentMessagesandforkSession).
- Breaking
- v0.3.332 & v0.3.331 (Late November 2026):
- Changed
Query.setPermissionMode()to resolve with{ mode }orundefinedinstead ofPromise<void>(v0.3.332, a TypeScript compile-time breaking change), added thePreSkillShellCommandhook event, enforcedfileCheckpointingEnabled: falseinrewindFiles(), and fixedlistSessions()without a limit exhausting open file descriptors (v0.3.331).
- Changed
- v0.3.329 & v0.3.328 (Mid-to-Late November 2026):
- Added
permissions.workingDirectoriesExclude(read only from--settingsand host-supplied settings), released large unread tool-result data after 30 seconds of idle time (when Remote Control is off), and ensuredPermissionRequesthook shell rewrites run their own permission check before deciding sandbox execution (v0.3.328).
- Added
- v0.3.327 & v0.3.325 (Mid-November 2026):
- Breaking option validation (
v0.3.327):query(),startup(), andprewarm()reject unserializable options (such as circular objects orBigIntfields), and hook matchers strictly require arrays rather thanSet, generators, or plain objects. - Sandbox, session & MCP hardening (
v0.3.325–v0.3.327): Sandboxed Bash commands are no longer auto-approved unlessautoAllowBashIfSandboxed: trueis set (v0.3.325), addedarchiveSession(),unarchiveSession(), andrefuseIfBusyonQuery.reloadPlugins(), deprecatedcreateSdkMcpServer()inside per-agentmcpServers(move them to top-levelmcpServers,v0.3.327), and extended background HTTPS MCP reconnect retries from ~27 minutes to ~24 hours (v0.3.327).
- Breaking option validation (
Breaking Changes, Bundling & Internals
Because @anthropic-ai/claude-agent-sdk orchestrates a native subprocess (Claude Code) over structured stdio/JSON-RPC, most subtle production bugs stem from binary resolution, bundle duplication, and hook/permission contracts.
Root vs. /core Entry & bun build --compile
The npm package documentation highlights two distinct import paths for TypeScript applications:
- Root entry (
@anthropic-ai/claude-agent-sdk): Ships zero runtime dependencies by inlining dependencies into a self-contained bundle—ideal for standalone Node/Bun scripts. /coreentry (@anthropic-ai/claude-agent-sdk/core): Exportsquery(),startup(),prewarm(),tool(),createSdkMcpServer(),getSessionInfo(), session mutations, andresolveSettings()while omitting heavy transcript listing/import helpers. Its eagerly loaded code is roughly one-quarter the size of the root entry, and it delegateszod(^4) and@modelcontextprotocol/sdk(^1.29) to your application'speerDependenciesso bundlers do not duplicate them. Never import both the root entry and/corein the same process, as they maintain separate class instances and runtime state.
When compiling single-file executables with bun build --compile, require.resolve cannot locate the optional platform binary inside Bun's virtual $bunfs filesystem. Use the SDK's @anthropic-ai/claude-agent-sdk/extract helper to materialize the embedded binary at startup:
import binPath from "@anthropic-ai/claude-agent-sdk-darwin-arm64/claude" with { type: "file" };
import { extractFromBunfs } from "@anthropic-ai/claude-agent-sdk/extract";
import { query } from "@anthropic-ai/claude-agent-sdk/core";
const cliPath = extractFromBunfs(binPath);
for await (const message of query({
prompt: "Audit src/auth for unvalidated JWT claims and summarize findings.",
options: {
pathToClaudeCodeExecutable: cliPath,
mcpServersDelivery: "initialize", // Default in 0.3.333+; requires Claude Code >= 2.1.326
autoAllowBashIfSandboxed: false, // Explicit opt-in required since 0.3.325
},
})) {
if (message.type === "result") {
// Always inspect subtype before reading result; capped/failed runs omit result
console.log({
subtype: message.subtype,
turns: message.num_turns,
costUsd: message.total_cost_usd,
});
}
}
Security & Sandbox Hardening Notes
Two production details verified in TestMu AI's December 1, 2026 SDK analysis and the official GitHub changelog deserve special attention:
- Unbounded turn & spend defaults: Both
max_turnsandmax_budget_usdare unset by default ("no limit"). Always set explicit budgets in autonomous pipelines and inspectmessage.subtype(error_max_budget_usd,error_during_execution,error_max_structured_output_retries) before readingmessage.result. - CI optional-dependency trap: Because the native Claude Code binary is delivered via platform-scoped
optionalDependencies(such as@anthropic-ai/claude-agent-sdk-linux-x64or-win32-x64), runningnpm ci --omit=optionalin Docker builds strips the binary and breaksquery()unlesspathToClaudeCodeExecutablepoints to a pre-installedclaudebinary.
Ecosystem Comparison & Upgrade Checklist
How does @anthropic-ai/claude-agent-sdk 0.3.334 stack up against its TypeScript/JavaScript agent framework peers in late 2026? Drawing on npm registry metadata and Blocksize AI Workshop's November 2026 telemetry:
| Package | Latest / Tracked Version | Oct–Nov 2026 npm Scale | Runtime Model & Dependencies | License & Ecosystem Fit |
|---|---|---|---|---|
@anthropic-ai/claude-agent-sdk (npm) |
0.3.334 (Dec 2, 2026) |
15.8M/wk; 83M (30d to Nov 26) | Bundles native Claude Code binary; 0 root deps (zod ^4 peer in /core) |
Commercial Terms; coding, file-edit, MCP & bash agents |
@langchain/langgraph (Blocksize) |
Graph runtime (1.x line) |
18.5M/mo (Oct 2026) | Pure JS/TS state-graph runtime; provider-agnostic | MIT; custom multi-provider DAGs & LangSmith |
@mastra/core (Blocksize) |
TypeScript agent framework | 10.9M/mo (Oct 2026) | Pure TS workflow/RAG/agent framework | Open-source; full-stack TS web & workflow apps |
@openai/agents (Blocksize) |
OpenAI Agents JS SDK | 9.9M/mo (Oct 2026) | Lightweight JS/TS loop over OpenAI Responses API | MIT; OpenAI-native multi-agent handoffs |
Upgrade Checklist for 0.3.334
Before bumping @anthropic-ai/claude-agent-sdk to 0.3.334 in package.json:
- Verify external Claude Code binary versions: If you override
pathToClaudeCodeExecutable(orCLAUDE_CODE_EXECUTABLE), ensure the target binary is>= 2.1.326to accept'initialize'MCP delivery, or explicitly setmcpServersDelivery: 'argv'. - Update
Query.setPermissionMode()callers: RemovePromise<void>assumptions (v0.3.332) and handle{ mode } | undefined. - Check
autoCompactWindowon 1M-context workloads: If your agents rely on compacting only near 1M tokens rather than~400K, overrideautoCompactWindowundermodelSettings(v0.3.334). - Convert hooks & MCP server placements: Ensure all hook matchers pass arrays (not
Setor generators,v0.3.327), and move any per-agentcreateSdkMcpServer()definitions to top-levelmcpServers. - Preserve
optionalDependenciesin Docker/CI: Never pass--omit=optional(or--no-optional) duringnpm ciunless you bundle a standaloneclaudebinary separately. - Pick one entry point: Standardize imports on either
@anthropic-ai/claude-agent-sdkor@anthropic-ai/claude-agent-sdk/core—never mix both in one bundle.
Frequently Asked Questions
What is the biggest breaking change in @anthropic-ai/claude-agent-sdk 0.3.333–0.3.334?
In v0.3.333, mcpServersDelivery switched its default from 'argv' to 'initialize', passing MCP server configurations inside the JSON initialize request instead of CLI arguments. Any host pointing pathToClaudeCodeExecutable at a Claude Code binary older than 2.1.326 will fail unless updated or explicitly configured with mcpServersDelivery: 'argv'.
Why did v0.3.334 change the auto-compact default to near 400K?
v0.3.334 lowered the per-model auto-compact threshold to near 400K tokens on most current 1M-context models (live on third-party providers and rolling out on first-party) to keep latency and context-rot in check. You can restore a higher threshold via autoCompactWindow under modelSettings.
When should I import @anthropic-ai/claude-agent-sdk/core instead of the root package?
Use /core when bundling inside a larger TypeScript app that already installs zod (^4) and @modelcontextprotocol/sdk (^1.29): /core avoids inlining those peer dependencies and loads roughly one-quarter of the root entry's eager code. Never import both entries in the same process.
Why does query() fail in CI when --omit=optional is enabled?
The SDK delivers its native Claude Code executable through platform-specific optionalDependencies (like @anthropic-ai/claude-agent-sdk-linux-x64). Omitting optional dependencies strips the binary, so either allow optional dependencies or provide pathToClaudeCodeExecutable.
How does SYSTEM_PROMPT_DYNAMIC_BOUNDARY work in v0.3.334?
v0.3.334 fixed a bug where SYSTEM_PROMPT_DYNAMIC_BOUNDARY was ignored on Bedrock, Agent Platform, Foundry, API gateways, and when experimental betas were off. Text placed above the boundary now reliably receives a prompt-cache breakpoint without changing the prompt content.
Sources
- npm —
@anthropic-ai/claude-agent-sdkv0.3.334 Package Page (Published December 2, 2026): https://www.npmjs.com/package/@anthropic-ai/claude-agent-sdk - GitHub —
anthropics/claude-agent-sdk-typescriptReleases (v0.3.325–v0.3.334) (Published December 2, 2026): https://github.com/anthropics/claude-agent-sdk-typescript/releases - GitHub —
anthropics/claude-agent-sdk-typescriptRepository (Accessed December 2, 2026): https://github.com/anthropics/claude-agent-sdk-typescript - Blocksize AI Workshop — "AI Agent Frameworks 2026: Claude Agent SDK, OpenAI Agents SDK, LangGraph and CrewAI by the Numbers" (Published November 28, 2026): https://ai.blocksize.hr/blog/en/ai-agent-frameworks-sdks-adoption-2026
- TestMu AI — "Claude Agent SDK: What It Is, How It Works and Setup" (Published December 1, 2026): https://www.testmuai.com/learning-hub/claude-agent-sdk/
- PyPI —
claude-agent-sdkPython Package (Accessed December 2, 2026): https://pypi.org/project/claude-agent-sdk/