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.

By 0xScorPionSon

8 min read

Claude Agent SDK 0.3.334: Breaking MCP Delivery, 400K Auto-Compact, and TypeScript /core Bundling

Claude Agent SDK 0.3.334 TypeScript agent loop, MCP initialize delivery, /core bundle entry, 400K cache boundary, and Bunfs binary extraction architecture

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_BOUNDARY being 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-compact defaults to near 400K tokens on most current 1M-context models (rolling out on first-party and live on third-party providers); set autoCompactWindow under modelSettings if 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 id as an active tool call.
    • Observability fields: Added duration_ms to shell task_notification events, old_cell_type to NotebookEdit replace/delete results, tool_use_result on subagent PushNotification and empty WebFetch messages, and consumer_terms_review_in_terminal, consumer_terms_accept_on_web, and resume_target_not_found to startup_failure_reason.
  • v0.3.333 (December 1, 2026 — Claude Code v2.1.333 parity):
    • Breaking mcpServersDelivery change: Defaulted mcpServersDelivery to 'initialize', sending MCP server configs inside the JSON initialize handshake rather than on the spawned CLI's argv command line (preventing command-line leakage and length limits). Apps launching an external Claude Code binary older than 2.1.326 with stdio, HTTP, or SSE mcpServers must upgrade the binary or pass mcpServersDelivery: 'argv'.
    • Transcript & subagent fixes: Fixed getSubagentMessages() dropping parallel tool calls/results and fixed getSessionMessages hanging on >2 GiB transcripts (alongside Bun fixes for getSubagentMessages and forkSession).
  • v0.3.332 & v0.3.331 (Late November 2026):
    • Changed Query.setPermissionMode() to resolve with { mode } or undefined instead of Promise<void> (v0.3.332, a TypeScript compile-time breaking change), added the PreSkillShellCommand hook event, enforced fileCheckpointingEnabled: false in rewindFiles(), and fixed listSessions() without a limit exhausting open file descriptors (v0.3.331).
  • v0.3.329 & v0.3.328 (Mid-to-Late November 2026):
    • Added permissions.workingDirectoriesExclude (read only from --settings and host-supplied settings), released large unread tool-result data after 30 seconds of idle time (when Remote Control is off), and ensured PermissionRequest hook shell rewrites run their own permission check before deciding sandbox execution (v0.3.328).
  • v0.3.327 & v0.3.325 (Mid-November 2026):
    • Breaking option validation (v0.3.327): query(), startup(), and prewarm() reject unserializable options (such as circular objects or BigInt fields), and hook matchers strictly require arrays rather than Set, generators, or plain objects.
    • Sandbox, session & MCP hardening (v0.3.325–v0.3.327): Sandboxed Bash commands are no longer auto-approved unless autoAllowBashIfSandboxed: true is set (v0.3.325), added archiveSession(), unarchiveSession(), and refuseIfBusy on Query.reloadPlugins(), deprecated createSdkMcpServer() inside per-agent mcpServers (move them to top-level mcpServers, v0.3.327), and extended background HTTPS MCP reconnect retries from ~27 minutes to ~24 hours (v0.3.327).

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:

  1. 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.
  2. /core entry (@anthropic-ai/claude-agent-sdk/core): Exports query(), startup(), prewarm(), tool(), createSdkMcpServer(), getSessionInfo(), session mutations, and resolveSettings() while omitting heavy transcript listing/import helpers. Its eagerly loaded code is roughly one-quarter the size of the root entry, and it delegates zod (^4) and @modelcontextprotocol/sdk (^1.29) to your application's peerDependencies so bundlers do not duplicate them. Never import both the root entry and /core in 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_turns and max_budget_usd are unset by default ("no limit"). Always set explicit budgets in autonomous pipelines and inspect message.subtype (error_max_budget_usd, error_during_execution, error_max_structured_output_retries) before reading message.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-x64 or -win32-x64), running npm ci --omit=optional in Docker builds strips the binary and breaks query() unless pathToClaudeCodeExecutable points to a pre-installed claude binary.

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 (or CLAUDE_CODE_EXECUTABLE), ensure the target binary is >= 2.1.326 to accept 'initialize' MCP delivery, or explicitly set mcpServersDelivery: 'argv'.
  • Update Query.setPermissionMode() callers: Remove Promise<void> assumptions (v0.3.332) and handle { mode } | undefined.
  • Check autoCompactWindow on 1M-context workloads: If your agents rely on compacting only near 1M tokens rather than ~400K, override autoCompactWindow under modelSettings (v0.3.334).
  • Convert hooks & MCP server placements: Ensure all hook matchers pass arrays (not Set or generators, v0.3.327), and move any per-agent createSdkMcpServer() definitions to top-level mcpServers.
  • Preserve optionalDependencies in Docker/CI: Never pass --omit=optional (or --no-optional) during npm ci unless you bundle a standalone claude binary separately.
  • Pick one entry point: Standardize imports on either @anthropic-ai/claude-agent-sdk or @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

  1. npm — @anthropic-ai/claude-agent-sdk v0.3.334 Package Page (Published December 2, 2026): https://www.npmjs.com/package/@anthropic-ai/claude-agent-sdk
  2. GitHub — anthropics/claude-agent-sdk-typescript Releases (v0.3.325 – v0.3.334) (Published December 2, 2026): https://github.com/anthropics/claude-agent-sdk-typescript/releases
  3. GitHub — anthropics/claude-agent-sdk-typescript Repository (Accessed December 2, 2026): https://github.com/anthropics/claude-agent-sdk-typescript
  4. 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
  5. 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/
  6. PyPI — claude-agent-sdk Python Package (Accessed December 2, 2026): https://pypi.org/project/claude-agent-sdk/

More on Packages

Tell us what is not working

A thirty-minute call, no deck and no obligation. You will leave with a straight answer about whether this is worth building - including if that answer is no.

Start a project

Direct line

hello@codebumble.net
Dhaka, Bangladesh  :   local timeCalls in English or Bangla