Skip to main content
← Frameworks

Claude Agent SDK

Anthropic
Python Open source MIT Coding framework CLI wrapper hooks Permission chain Claude only 8 axes checked Active Checked 2026-10-23

Read the two badges separately: the first is whether this page is backed by evidence, the second is whether the product is still maintained. An archived product can have complete evidence; complete evidence does not mean the product is active.

30-second check: should it make your shortlist?

In one line

The Python programming interface to Claude Code — a polished coding CLI turned into…

How you use it

Local / self-hosted · Framework / SDK

Licence / commercial use

Open licence

Read the original licence before commercial use
Mainland China

Direct in mainland · Not in filing list

These four cards help you rule things out, not decide for you. The real differences are in the eight questions and sources below.

Information not confirmed

  • The specific constraints of Anthropic's Commercial Terms (especially customer-facing scenarios)
  • The TypeScript version's authorization status
  • Multi-process concurrency semantics of session persistence
  • The exact shape and limits of session forking
  • All permission_mode values and the precedence details of can_use_tool
  • Compatibility differences between the bundled CLI version and a system-installed version

What it is: the Python programming interface to Claude Code. It turns a polished coding CLI into an object you can drive from Python. It is not a framework for building your own agent. It is also the only coding base among our ten objects that cannot switch models — every trade-off below follows from that.

Official README, first line: "Python SDK for Claude Agent."

When to use it, when not to

One line: it is a coding agent that has already been polished.

Swapping models and shaping the agent loop are the two things it cannot do.

Fits:

  • you want a coding agent that has already been polished — tool set, permission chain, hooks and session fork all included
  • your team works in Python
  • you are happy handing reasoning entirely to Claude

Not a fit:

  • you need a different model / self-hosted weights — ruled out outright
  • you need a framework-level custom agent loop — the loop shape is decided by Claude Code
  • you need multi-agent orchestration — it has no first-class agents-as-tools delegation

China availability domestic / direct access / CAC filing · snapshot 2026-10-23

Origin
foreign-made foreign entity (no matching filing entity in the CAC registry).
Direct access
direct OK docs site measured 200 direct.
CAC filing
not in filing list:not in the CAC public registry (13 batch attachments searched 2026-10-20, https://www.cac.gov.cn/2024-04/02/c_1713729983803145.htm); the product does not serve the mainland public, so filing does not apply.

Filing status is quoted from the CAC public registry (updated batch by batch; this site copies the number and does not interpret it). "Direct access" is this site's own reachability measurement from a mainland network, not a vendor promise. GitHub-hosted sites fluctuated on the measurement day — the note says so.

8 questions, one table

8 questions, each comparable item by item with its peers.

Model & openness

Claude only — there is no second path.

  • pyproject.toml has no optional dependencies like litellm / any-llm
  • every other harness on this site can attach self-hosted models (Ollama / vLLM / llama.cpp); this SDK cannot

⚠ This is its most fundamental difference from the other nine objects.

The local-quantization route recommended by the model layer (models.specul.com) does not work here.

Verified: the README contains no provider-agnostic wording.

Where it runs

A two-layer structure: "you operate a Python process + it drives a CLI subprocess."

Actual form: a pip package containing the Claude Code CLI.

The CLI then connects to the Anthropic API. In other words it is not "a library" but "a library with a CLI inside".

The CLI defaults to the bundled version but can point at a system install:

  • switch to a locally installed CLI: ClaudeAgentOptions(cli_path="/path/to/claude")
  • working directory: ClaudeAgentOptions(cwd="/path/to/project")

Verified: the README states the CLI ships bundled with the wheel; _cli_version.py has __cli_version__ = "2.1.286".

Local files

The default is the full file toolset, starting at full permissions.

README wording:

By default, Claude has access to the full Claude Code toolset (Read, Write, Edit, Bash, and others).

  • working directory: ClaudeAgentOptions(cwd="/path/to/project")

⚠ This is the biggest risk difference vs other objects on this site: by default it can read files, edit files and run Bash.

Tasks after shutdown

Kill the process and it stops — true "runs after shutdown" does not exist.

But sessions have official persistence and resume semantics. Storage location verified:

~/.claude/projects/<encoded-cwd>/*.jsonl; with CLAUDE_CONFIG_DIR set, under its projects/.

Resume comes in three flavors:

  • continue_conversation=True: resume the most recent session
  • resume=<session_id>: resume a specific session
  • fork_session=True: fork

Official note on resume: "picks up with full context from wherever the session left off"

Official sessions page wording:

Official wording: "A session is the conversation history the SDK accumulates... The SDK writes it to disk automatically"

One session equals one claude CLI subprocess; when the process stops, the loop stops.

Cross-host resume means mirroring transcripts to shared storage. The adapter is SessionStore.

⚠ The official docs remind: session persistence covers the conversation, not the filesystem.

For file rollback use file checkpointing.

Official wording: "Sessions persist the conversation, not the filesystem"

Tools & extensions

Two entry points with different capabilities — a key design detail.

  • query(): one-way prompting, can only use the CLI's built-in toolset
  • ClaudeSDKClient: two-way conversation, additionally unlocks custom tools and hooks

Custom tools are "in-process MCP servers" — official wording:

"in-process MCP servers that run directly within your Python application"

The official list of benefits has five items:

BenefitNote
No subprocess managementsame process as the app, no subprocess management
Better performancetool calls with no IPC overhead
Simpler deploymentsingle process instead of multiple
Easier debuggingall code in one process
Type safetytyped direct Python function calls

External MCP servers are still supported; the two can be mixed.

The mcp_servers dict can hold at the same time:

  • the output of create_sdk_mcp_server(...)
  • {"type":"stdio", ...} external servers
Context & memory

An easily overlooked mechanism: the system-prompt snapshot semantics.

Claude Code builds it on the session's first request, then reuses it on every later request.

It is still reused after resuming a session.

Changing a custom prompt does not take effect immediately.

The same goes for changed append text of the claude_code preset.

You must wait for the session to be compacted, or start a new session.

Unless snapshot is set to False (needs CLI 2.1.257+).

This is essentially an "immutable context snapshot" design.

It guarantees prompt determinism; the cost is delayed change effect.

This connects directly to this site's "state ≠ context" discussion.

Permissions & limits

Conclusion first: everything is open by default; you tighten permissions yourself.

The official evaluation chain is the most detailed one seen on this site so far. README wording:

allowed_tools is a permission allowlist: listed tools are auto-approved, and unlisted tools fall through to permission_mode and can_use_tool for a decision. It does not remove tools from Claude's toolset. To block specific tools, use disallowed_tools.

Which unpacks into four points:

  • allowed_tools is an admission allowlist: listed = auto-approved
  • unlisted tools fall through to permission_mode and can_use_tool
  • it does not remove tools from the toolset
  • to actually disable a tool, use disallowed_tools

Hooks provide deterministic interception:

  • they are "Python functions invoked by Claude Code *applying* them (not Claude)"
  • interception point: PreToolUse returning permissionDecision: "deny" plus a reason
  • official example: blocking Bash commands

⚠ The default starting point is all tools + no sandbox; tightening requires deliberate configuration.

Three switches:

  • disallowed_tools
  • hooks
  • permission_mode
Best for

In one line: it is an already-polished coding agent.

Swapping models and customizing loop shape — it cannot do that.

Fits:

  • wanting an already-polished coding agent — toolset, permission chain, hooks, session fork all present
  • teams using Python
  • being willing to hand reasoning entirely to Claude

Does not fit:

  • needing to swap models / attach self-hosted weights — ruled out outright
  • needing framework-level custom agent loops — the loop shape is decided by Claude Code
  • needing multi-agent orchestration — it has no first-class agents-as-tools delegation mechanism

Licence and terms of use

MIT

Top misconception

  • Assuming it is "Anthropic's version of the OpenAI Agents SDK" — it is not. It is the SDK for the Claude Code CLI; its capabilities come from that CLI, not from the framework
  • Assuming allowed_tools restricts the toolset — the official docs state "It does not remove tools from Claude's toolset"; use disallowed_tools to disable
  • Assuming the default is safe — the default is the full toolset (Read/Write/Edit/Bash), with no sandbox layer
  • Assuming a system prompt change takes effect immediately — a snapshot freezes it. It lands only after a compact or a new session (unless snapshot=False)
  • Assuming MIT means no additional terms — Anthropic's commercial terms still apply (see the body above)
  • Assuming the TypeScript build is licensed like the Python one: verification found no LICENSE file in the TS build, and the licence API returns null. Its licensing status is unknown (checked 2026-09-30)

Evidence sources

Checked 2026-10-23,Content updated 2026-09-30。This is the date of the entry, not a claim that every field was rechecked that day.

TypeNameLink
repoClaude Agent SDK for Python · repositoryhttps://github.com/anthropics/claude-agent-sdk-python
docsOfficial docs (Python)https://platform.claude.com/docs/en/agent-sdk/python
docsPermission guide (the authoritative statement of the evaluation order)https://platform.claude.com/docs/en/agent-sdk/permissions
docsHooks (official dedicated chapter)https://platform.claude.com/docs/en/agent-sdk/hooks
docsClaude Code toolset list (tools available to Claude)https://code.claude.com/docs/en/settings#tools-available-to-claude
docsModifying system prompts (the authoritative statement of snapshot semantics)https://code.claude.com/docs/en/agent-sdk/modifying-system-prompts
docsWork with sessions (session write-to-disk location, continue/resume/fork, cross-host SessionStore, verified 2026-10-08)https://code.claude.com/docs/en/agent-sdk/sessions
docsHosting the Agent SDK (subprocess model, local-disk state, cross-host persistence, verified 2026-10-08)https://code.claude.com/docs/en/agent-sdk/hosting
docsAnthropic Commercial Terms (pointed to by the README's final section, key to authorization)https://www.anthropic.com/legal/commercial-terms
changelogReleases (0.2.163 @ 2026-09-30)https://github.com/anthropics/claude-agent-sdk-python/releases
changelogCHANGELOG (breaking changes from Claude Code SDK <0.1.0)https://github.com/anthropics/claude-agent-sdk-python/blob/main/CHANGELOG.md

Test notes

This site has not completed measured runs.

The test protocol is at protocols/framework/_protocol.md.

Suggested measurement:

#What to testWhy it is worth testing
1How much a pip install actually pulls in (including the bundled CLI's size)the CLI ships with the package; deployment-size impact unknown
2Which directories the agent can actually reach under default configdefault full toolset with no sandbox; the boundary needs measuring
3Whether disallowed_tools or hooks take effect firstthe README only gives an evaluation-order overview; only measurement tells
4What granularity resume restores session state tothis site's top concern: "reliable long-running operation"
5How long after changing the system prompt it takes effect (test compact trigger conditions)the boundary of snapshot semantics

⚠ First, the most misunderstood point: it wraps a CLI, it is not a framework

The README's first line already says it:

Python SDK for Claude Agent. The Claude Code CLI is automatically bundled with the package — no separate installation required!

Which CLI is bundled has an exact record:

verified _cli_version.py: __cli_version__ = "2.1.286" (the exact bundled CLI version).

This means the capability boundary is fixed:

What you might thinkReality
importing an agent frameworkimporting a wheel containing a CLI, which then connects to the API
the agent loop is defined by the SDKthe agent loop is defined by the Claude Code CLI
you can change the agent's shapeyou can only configure the switches it exposes via options

The fundamental difference vs the OpenAI Agents SDK:

  • the latter is a framework that builds its own agent loop (primitives-only)
  • this SDK is the SDK-ification of an existing CLI

This is the contrast pair this site most needs to make clear.

The only coding base of the ten that cannot swap models

The provider-swap path is closed on this SDK.

OpenAI Agents SDKClaude Agent SDK
providerprovider-agnostic, 100+Claude only
swapping to self-hosted weightspossible (litellm / any-llm extra)not possible
agent loopthe SDK gives primitivesthe CLI decides the shape

⚠ This directly closes one of this site's recommended routes.

  • the model layer (models.specul.com) mainly recommends local quantized models + Ollama/vLLM self-hosting
  • it does not work on this SDK — to use local weights you must switch solutions

Permissions: the official docs give a full evaluation chain, but the default is wide open

The official docs give a complete permission evaluation chain — the most detailed one seen on this site so far.

This README passage is the authoritative statement:

allowed_tools is a permission allowlist: listed tools are auto-approved, and unlisted tools fall through to permission_mode and can_use_tool for a decision. It does not remove tools from Claude's toolset. To block specific tools, use disallowed_tools.

Translated into a table:

MechanismRoleCommonly misunderstood
allowed_toolsadmission allowlist, listed = auto-approved⚠ does not remove tools from the toolset
permission_modeunlisted tools are decided heree.g. acceptEdits auto-accepts file edits
can_use_toolcustom callback functionthe official docs give the full evaluation order
disallowed_toolsactually disables toolsto truly block, use this
hooksPreToolUse returns deny plus a reasondeterministic interception, executed by the application layer, not the model layer

⚠ The default starting state must be known:

By default, Claude has access to the full Claude Code toolset (Read, Write, Edit, Bash, and others).

By default it has Read / Write / Edit / Bash, with no sandbox layer.

Tightening requires deliberate configuration, three switches:

  • disallowed_tools
  • hooks
  • permission_mode

The positioning of hooks deserves its own note:

  • they are "Python functions invoked by Claude Code *applying* them (not Claude)"
  • interception happens in deterministic code, not by relying on the model to self-restrain

Contrast with Deep Agents:

  • that one's stance is "trust the LLM, don't expect the model to self-restrain"
  • Anthropic's answer: put interception in the application layer

Custom tools = in-process MCP servers (a tidy design)

Custom tools are not plain function calls but "in-process MCP servers."

Official wording:

"in-process MCP servers that run directly within your Python application"

The official list of benefits has five items:

BenefitNote
No subprocess managementsame process as the app, no subprocess management
Better performancetool calls with no IPC overhead
Simpler deploymentsingle process instead of multiple
Easier debuggingall code in one process
Type safetytyped direct Python function calls

External MCP servers are still supported; the two can be mixed.

The mcp_servers dict can hold at the same time:

  • the output of create_sdk_mcp_server(...)
  • {"type":"stdio", ...} external servers

⚠ Note the capability boundary:

  • custom tools and hooks are only available under ClaudeSDKClient
  • query() cannot use them

"State ≠ context": a counterintuitive snapshot design here

The system prompt has "snapshot" semantics.

Changing the prompt mid-session does not take effect immediately.

README wording:

Claude Code builds the system prompt on a session's first request, records it, and reuses it on every later request, including after you resume the session. A changed custom prompt, or changed append text... then has no effect until the session is compacted or you start a new session. To rebuild the prompt on every request instead... set snapshot to False.

To rebuild every time, explicitly set snapshot: False.

This needs CLI 2.1.257+.

The README also records a historical bug:

"Before 2.1.265, a session with an append or custom prompt recorded it only when snapshot was True"

This is essentially an "immutable context snapshot": it guarantees prompt determinism; the cost is delayed changes.

Relationship to this site's stance:

  • other harnesses discuss "how to compact/persist context"
  • this one discusses "how to freeze context"

It keeps the prompt constant within one session, avoiding unpredictable behavior from prompt drift.

This is a third approach, recorded here for the first time on this site (marked as this site's observation, not official wording).

The licensing truth: MIT, but not "no additional conditions"

Conclusion: the repository is MIT, but usage is still governed by Anthropic's Commercial Terms.

README final-section wording:

Use of this SDK is governed by Anthropic's Commercial Terms of Service, including when you use it to power products and services that you make available to your own customers and end users, except to the extent a specific component or dependency is covered by a different license.

The repository license marker is MIT.

the license API confirms spdx_id: MIT.

But usage is governed by Anthropic's Commercial Terms.

Especially the clause about "using it to power products/services for your own customers".

⚠ This site's note: this is not "not open source", nor "cannot be used commercially".

But you must read those commercial terms before building a product; the MIT marker alone is not a complete authorization judgment.

One verification finding attached:

  • the TypeScript repository: anthropics/claude-agent-sdk-typescript
  • 1,780★, active
  • no LICENSE file, the license API returns null

Whether its authorization status matches the Python version is not verified.

The Python version is MIT + commercial terms; the TS version has no file to check.

If selecting the TS version, authorization needs separate confirmation.

Appendix: the repository description fields are empty

Two metadata fields are empty; recorded as-is.

verified: description is null (GitHub API), and homepage is also null. The docs entry is in the README's first line: platform.claude.com/docs/en/agent-sdk/python.

Recording it this way prevents readers from assuming the missing information is because we did not check.

Verification notes

Basis for confidence: partial.

Downgrade time: 2026-10-03, downgraded from verified to partial.

Why downgraded: the subject of the ❌ items below is this site's evidence gap, not "not provided officially". Per the v3 rule "say unknown when unknown", marking verified while these items exist would be inflated, hence partial.

Three main gaps:

  • the specific clauses of Anthropic's Commercial Terms
  • the TS version's license status
  • hooks' lifecycle boundaries

Verified:

  • ✅ repository exists and star count (8,334 · rolling check 2026-10-23)
  • ✅ license (license API returns MIT)
  • ✅ last push (2026-10-22, still active)
  • ✅ latest version 0.2.173 (released 2026-10-22)
  • ✅ bundled CLI version 2.1.286 (_cli_version.py verbatim)
  • ✅ full README — permission evaluation chain, hooks positioning, error-type list, default full toolset wording
  • ✅ full README — custom tools as in-process MCP servers, system-prompt snapshot semantics
  • ✅ the licensing final-section verbatim
  • ✅ the 0.2.162 recorded in the v3 plan has been overtaken (latest 0.2.173 at the 2026-10-23 rolling check)

⚠ Anomaly findings:

  • repository description and homepage are both null
  • the TS version has no LICENSE file; the license API returns null

❌ Not verified:

  • the specific clauses of Anthropic's Commercial Terms (original text not read; legal territory)
  • multi-process concurrency semantics of sessions
  • the exact shape and limits of session forking
  • the full precedence chain of can_use_tool and permission_mode (the README gives an overview only; details are in the permissions chapter)

One plan-data correction:

v3 plan §2.2 recorded v0.2.162.

At verification time v0.2.163 had been released, later than the plan was written.

This again confirms "snapshots go stale; verification must happen live."

Related entries

  • OpenAI Agents SDKThe pair this site should contrast most: both from model vendors, both in the "coding base" tier. The OpenAI side is a build-your-own-loop framework + provider-agnostic; the Anthropic side is a CLI's SDK + Claude only.
  • Codex SDKThe third vendor's same-tier choice. The three are three answers to the same question: build your own framework / wrap a CLI / wrap a CLI.
  • Deep AgentsPermission-philosophy contrast: "trust the LLM" vs "deterministic interception at the application layer"
  • Hermes AgentOpposite routes, different vendors (this site's former is Anthropic, the latter Nous Research): that one is a self-hosting-first general harness; this entry only wraps Anthropic's own CLI.
  • Claude Code CLIOther layer · AI coding

Same-category peers

Look at these three before reading further

Selected by overlap in jobs, not ranked. Compare where it runs, licence and status first; if one of the three fails, skip it.

ObjectWhereLicenceEvidence / statusWhat it is for
Codex SDKLocal / self-hostedOpen licence8 questions checked
Active
"Turns the Codex CLI into an object you can drive inside a Node process"
DSPyLocal / self-hostedOpen licence8 questions checked
Active
DSPy turns 'tuning prompts' into a programming problem (MIT, Stanford NL
Pydantic AILocal / self-hostedOpen licence8 questions checked
Active
Pydantic AI is the type-safe Python agent loop — official README: "Pydan

Same vendor

More from Anthropic

One vendor’s products are often split across categories. This list puts them together so you do not have to assemble them across five sites.

This page is generated from the ai-handbook data layer (CC BY 4.0). For the judging criteria and method notes, see METHODOLOGY.md.