Tool pages / Claude Agent SDK
Claude Agent SDK 0.3.296: latest version, API diff and gotchas
Latest: Claude Agent SDK 0.3.296, released (release notes).
The latest Claude Agent SDK is 0.3.296 (@anthropic-ai/claude-agent-sdk on npm), released on 2026-10-09 at 19:28 UTC (npm published 16:59 UTC); install with npm i @anthropic-ai/claude-agent-sdk@latest. Python applications install claude-agent-sdk (0.2.165 on PyPI, released 2026-10-08 18:18 UTC). Release 0.3.296 surfaces claude_code_version in the initialize control response, adds autoCompactWindow to AgentDefinition for subagent context compaction, merges sandbox options with inline settings, and raises upfront MCP tool description character limits from 2,048 to 4,096.
How do I install or upgrade to Claude Agent SDK 0.3.296?
TypeScript / JavaScript (Node.js 18 or later):
npm i @anthropic-ai/claude-agent-sdk@latest
npm ls @anthropic-ai/claude-agent-sdk # @anthropic-ai/claude-agent-sdk@0.3.296Python (Python 3.10 or later):
pip install -U claude-agent-sdk
python3 -c "import claude_agent_sdk; print(getattr(claude_agent_sdk, '__version__', 'installed'))" # 0.2.165TypeScript compiler prerequisites (tsconfig.json):
npm i -D @types/node typescript@^5.6
# In tsconfig.json, ensure "lib": ["ES2022", "ESNext.Disposable"] and "moduleResolution": "NodeNext"Claude Agent SDK key facts
- Dual ecosystem with bundled binary: The SDK runs Claude Code's agent loop programmatically in TypeScript (
@anthropic-ai/claude-agent-sdkon npm, repoanthropics/claude-agent-sdk-typescript) and Python (claude-agent-sdkon PyPI, repoanthropics/claude-agent-sdk-python). Both packages bundle a native Claude Code CLI binary as platform-specific optional dependencies, running the agent loop over stdio. - Latest releases: TypeScript SDK 0.3.296 (GitHub release 2026-10-09 19:28 UTC; npm published 16:59 UTC; parity with Claude Code 2.1.296). Python SDK 0.2.165 (GitHub release 2026-10-08 18:21 UTC; PyPI published 18:18 UTC).
- Download demand: npm recorded 11,982,584 downloads for
@anthropic-ai/claude-agent-sdkfrom 2026-10-02 through 2026-10-08. GitHub repositoryanthropics/claude-agent-sdk-typescripthas 1,796 stars. - Runtime requirements: Node.js 18.0.0 or later for TypeScript; Python 3.10 or later for Python. Peer dependencies in npm:
zod ^4.0.0,@anthropic-ai/sdk >=0.93.0, and@modelcontextprotocol/sdk ^1.29.0. - Entry points: npm package exports
.(sdk.mjs/sdk.d.ts),./core(core.mjs/core.d.ts),./bridge(bridge.mjs/bridge.d.ts),./browser(browser-sdk.js/browser-sdk.d.ts),./extract(extractFromBunfs.js/extractFromBunfs.d.ts), and./sdk-tools(sdk-tools.d.ts). The legacy./assistantsubpath was removed from the package exports in 0.3.181. - Subagent compaction: 0.3.296 added
autoCompactWindowtoAgentDefinition, letting subagents auto-compact earlier than the parent session's context window. - Tool description expansion: 0.3.296 doubled the upfront MCP tool description limit and server instruction cap from 2,048 to 4,096 characters. 0.3.295 cut descriptions loaded via tool search at 16,384 characters.
What changed in the last 5 Claude Agent SDK releases?
Claude Agent SDK 0.3.296 (2026-10-09 19:28 UTC)
- Added
claude_code_versionto theinitializecontrol response so clients know the CLI version before the first turn. (source) - Added
autoCompactWindowtoAgentDefinition, so a subagent can auto-compact earlier than the main conversation's window. (source) - Fixed the
sandboxoption discarding an inlinesettings.sandboxblock: the two now merge, option values win, and deny/credential lists combine. (source) - Changed the default limit on MCP tool descriptions sent up front and on MCP server instructions from 2,048 to 4,096 characters. (source)
- Changed permission answers arriving after restart: over 4,096
updatedPermissionsentries count as denial, and malformed lists are ignored as a whole. (source)
Claude Agent SDK 0.3.295 (2026-10-08 19:48 UTC)
- Added
overageEnabledtoSDKRateLimitInfoto indicate whether extra usage is enabled on usage-limit warnings. (source) - Changed MCP tool descriptions loaded through tool search to be cut at 16,384 characters instead of 2,048. (source)
- Fixed assistant text blocks losing their
citationsin streamed responses. (source) - Changed named option passing to Claude Code: named option values are now sent in the same argument as their flag (
--flag=value). (source) - Capped MCP Apps
tool_use_result:structuredContentor_metaover 8,388,608 JSON characters is omitted. (source)
Claude Agent SDK 0.3.294 (2026-10-08 05:03 UTC)
- Updated to parity with Claude Code v2.1.294. (source)
Claude Agent SDK 0.3.293 (2026-10-07 18:10 UTC)
Claude Agent SDK 0.3.292 (2026-10-06 18:59 UTC)
- Added
agent_idto subagentassistantandusermessages, matching the subagent'stask_idand persisting across resumes. (source) - Added
parent_task_idtotask_startedevents andbackground_tasks_changedentries, tracking the parent subagent. (source) - Added typed
sectionsandnotesto theListAgentstool'stool_use_result, removing the need to parse text output. (source) - Fixed subagents with declared auto permission mode having tool calls evaluated by auto-mode classifier when auto mode is unavailable. (source)
Which Claude Agent SDK exports and members were added or removed?
Claude Agent SDK 0.3.295 โ 0.3.296
0 exports added, 0 removed, 7 exports with public members added or removed; 12 declarations changed in any way.
Method: bin/tool-snapshot installed both versions in a throwaway Linux sandbox and listed every export of every package entry point from the type declarations with the TypeScript compiler API (741 and 741 exported symbols), then bin/tool-diff compared them. In the tables, "command" is an exported symbol and "flags" are its public members (function parameters in parentheses).
| Export | Members added | Members removed |
|---|---|---|
@anthropic-ai/claude-agent-sdk AgentDefinition | autoCompactWindow | none |
@anthropic-ai/claude-agent-sdk SDKControlInitializeResponse | claude_code_version | none |
@anthropic-ai/claude-agent-sdk/bridge AttachBridgeSessionOptions | claudeCodeVersion | none |
@anthropic-ai/claude-agent-sdk/core AgentDefinition | autoCompactWindow | none |
@anthropic-ai/claude-agent-sdk/core SDKControlInitializeResponse | claude_code_version | none |
@anthropic-ai/claude-agent-sdk/sdk-tools FileReadInput | allow_large | none |
@anthropic-ai/claude-agent-sdk/sdk-tools.js FileReadInput | allow_large | none |
- Consecutive releases across 0.3.295 and 0.3.296. Total exported symbols remained steady at 741 across all 6 package entry points.
autoCompactWindow?: numberwas added toAgentDefinitionin both root and./coreentry points, allowing subagents to trigger context compaction independently before the main session's window fills.claude_code_version: stringwas added toSDKControlInitializeResponse(andclaudeCodeVersiontoAttachBridgeSessionOptions), letting hosts inspect the bundled engine version on initialization before sending user turns.FileReadInput.allow_large?: booleanadded in./sdk-toolsdeclarations reflects Claude Code 2.1.296's Read tool option for reading large files past default chunk limits.
Claude Agent SDK 0.2.141 โ 0.3.296
405 exports added, 21 removed, 108 exports with public members added or removed; 141 declarations changed in any way.
Method: bin/tool-snapshot installed both versions in a throwaway Linux sandbox and listed every export of every package entry point from the type declarations with the TypeScript compiler API (357 and 741 exported symbols), then bin/tool-diff compared them. In the tables, "command" is an exported symbol and "flags" are its public members (function parameters in parentheses).
Exports added:
@anthropic-ai/claude-agent-sdk BackgroundTaskSummary@anthropic-ai/claude-agent-sdk ClaimOptions@anthropic-ai/claude-agent-sdk DirectoryAddedHookInput@anthropic-ai/claude-agent-sdk FastModeDisabledReason@anthropic-ai/claude-agent-sdk McpServerProvenance@anthropic-ai/claude-agent-sdk MessageDisplayHookInput@anthropic-ai/claude-agent-sdk MessageDisplayHookSpecificOutput@anthropic-ai/claude-agent-sdk SDKActiveGoalMessage@anthropic-ai/claude-agent-sdk SDKBackgroundTasksChangedMessage@anthropic-ai/claude-agent-sdk SDKCommandsChangedMessage
Exports removed:
@anthropic-ai/claude-agent-sdk unstable_v2_createSession@anthropic-ai/claude-agent-sdk unstable_v2_prompt@anthropic-ai/claude-agent-sdk unstable_v2_resumeSession@anthropic-ai/claude-agent-sdk SDKSession@anthropic-ai/claude-agent-sdk SDKSessionOptions@anthropic-ai/claude-agent-sdk/assistant AssistantSession
| Export | Members added | Members removed |
|---|---|---|
@anthropic-ai/claude-agent-sdk AgentDefinition | autoCompactWindow | none |
@anthropic-ai/claude-agent-sdk/sdk-tools FileReadInput | allow_large | none |
- Major API evolution from the 0.2 line (0.2.141 on 2026-05-13) to the current 0.3 line (0.3.296 on 2026-10-09). Symbol count more than doubled from 357 to 741.
- Removed legacy experimental v2 session APIs (
unstable_v2_createSession,unstable_v2_prompt,unstable_v2_resumeSession,SDKSession,SDKSessionOptions) and deleted the./assistantentry point in favor of the unifiedquery()generator and./corearchitecture. - Introduced comprehensive lifecycle hooks (
DirectoryAddedHook,MessageDisplayHook,PreModelSwitchHook,PostModelSwitchHook), background task coordination events, and full subagent hierarchy support (parent_task_id,agent_id,run_id).
What breaks when upgrading Claude Agent SDK, and how do I migrate?
| Version | Change | Migration |
|---|---|---|
| 0.3.142 | Removed deprecated v2 session API exports (unstable_v2_createSession, unstable_v2_prompt, unstable_v2_resumeSession, SDKSession, SDKSessionOptions). | Migrate all session management to query(). For multi-turn interactions, pass an AsyncIterable<SDKUserMessage>; to resume existing sessions, pass options.resume with the session ID. |
| 0.3.181 | Removed the @anthropic-ai/claude-agent-sdk/assistant export subpath from the npm package exports. | Import supported APIs from @anthropic-ai/claude-agent-sdk or @anthropic-ai/claude-agent-sdk/core; do not import from @anthropic-ai/claude-agent-sdk/assistant. |
| 0.3.142 | MCP servers connect in the background by default on session startup; sessions start immediately without blocking for external MCP readiness, reporting status: 'pending' in init. | Set MCP_CONNECTION_NONBLOCKING=0 to restore blocking connection behavior up to 5s before turn 1, or mark critical servers with alwaysLoad: true in your server configuration. |
| 0.3.142 | Headless and SDK sessions replaced TodoWrite with dedicated Task tools (TaskCreate, TaskUpdate, TaskGet, TaskList). | Update custom tool consumers and handlers to process incremental Task tool invocations by task ID rather than expecting monolithic todo snapshots. |
| 0.3.296 | Permission answers arriving after process restart enforce strict parsing parity with live turns: answer lists with over 4,096 updatedPermissions entries are treated as explicit denials, and malformed update arrays are rejected as a unit. | Batch permission updates under 4,096 items and ensure permission serialization preserves valid rule schemas across host restarts. |
What Claude Agent SDK errors did we reproduce, and how do I fix them?
`canUseTool` callback is bypassed when tool names are in `allowedTools` (Claude Agent SDK 0.3.296)
import { query } from "@anthropic-ai/claude-agent-sdk";
const q = query({ prompt: "hello", options: { allowedTools: ["Read"], canUseTool: async () => ({ allow: true }) } });
for await (const msg of q) {}(node:3) [CLAUDE_SDK_CAN_USE_TOOL_SHADOWED] Warning: canUseTool will not be invoked for: Read. Bare allowedTools entries auto-approve the whole tool before the callback is consulted. To gate every tool call, use a PreToolUse hook; or remove the bare names from allowedTools so they fall through to canUseTool. Allow rules from settings files can also shadow the callback but are not visible here.Fix: Remove bare tool names from allowedTools to allow calls to be evaluated by canUseTool, or use a PreToolUse hook to enforce fine-grained inspection on all tool calls. (source)
`query()` fails immediately with `Not logged in` if credentials are not configured (Claude Agent SDK 0.3.296)
import { query } from "@anthropic-ai/claude-agent-sdk";
const q = query({ prompt: "hello" });
for await (const msg of q) {}caught: Error Claude Code returned an error result: Not logged in ยท Please run /loginFix: Set the ANTHROPIC_API_KEY environment variable in the process running the SDK, or run claude /login to configure OAuth credentials before initializing the query generator. (source)
Removed session and assistant imports fail to compile (Claude Agent SDK 0.3.296)
import { unstable_v2_createSession } from "@anthropic-ai/claude-agent-sdk";
import { AssistantSession } from "@anthropic-ai/claude-agent-sdk/assistant";probe.ts(1,10): error TS2305: Module '"@anthropic-ai/claude-agent-sdk"' has no exported member 'unstable_v2_createSession'.
probe.ts(2,34): error TS2307: Cannot find module '@anthropic-ai/claude-agent-sdk/assistant' or its corresponding type declarations.Fix: Replace unstable_v2_createSession with query({ prompt, options }), and import supported APIs from @anthropic-ai/claude-agent-sdk or @anthropic-ai/claude-agent-sdk/core. (source)
Claude Agent SDK release history by month
2026-10:
- 0.3.296: Surfaced
claude_code_versionin initialize control response and addedautoCompactWindowtoAgentDefinition. (source) - 0.3.295: Added
overageEnabledtoSDKRateLimitInfoand raised MCP tool search description limit to 16,384 characters. (source) - 0.3.292: Added
agent_id,parent_task_id, andrun_idfor tracking nested background subagent execution trees. (source)
2026-09:
2026-08:
2026-07:
2026-06:
2026-05:
Sources
- GitHub Releases: anthropics/claude-agent-sdk-typescript (read 2026-10-10)
- CHANGELOG.md at v0.3.296 (read 2026-10-10)
- npm package: @anthropic-ai/claude-agent-sdk (read 2026-10-10)
- npm download statistics: @anthropic-ai/claude-agent-sdk (read 2026-10-10)
- PyPI package: claude-agent-sdk (read 2026-10-10)
- GitHub repository: anthropics/claude-agent-sdk-typescript (read 2026-10-10)
- Anthropic Claude Code SDK documentation (read 2026-10-10)
- npm package exports at v0.3.181 (read 2026-10-10)
Last verified: 2026-10-10.