Claude Agent SDK(Anthropic)
1. 介绍
1.1. 平台定位与来源
Claude Agent SDK 是 Anthropic 官方提供的智能体运行时库,用于把 Claude Code 那一套「工具 + 智能体循环 + 上下文管理」以编程方式嵌入开发者自己的进程,语言覆盖 Python 与 TypeScript。Anthropic 官方工程博客对它的定位原话是:
"The Claude Agent SDK is a powerful, general-purpose agent harness adept at coding, as well as other tasks that require the model to use tools to gather context, plan, and execute."
这句话在整个 AI Harness 调研中具有定调意义:头部模型厂商第一次把 "harness" 这个词写进产品定义,而不是把它当作内部实现的黑话。它印证了参数卡中的核心判断——Harness 不负责提升模型智能,而负责把模型的不确定性转化为工程上的可预期性。
需要强调的是 SDK 的三重边界:
- 与 Claude Code CLI 的边界:CLI 是人在回路的终端工具,SDK 是程序在回路的编程库;二者走的是同一条 agent loop。
- 与 Anthropic Client SDK 的边界:Client SDK 只暴露 Messages API,工具循环要开发者自己写;Agent SDK 把工具循环、权限、压缩、会话全部内置。
- 与 Managed Agents 的边界:Managed Agents 是 Anthropic 托管的 REST API 产品,沙箱由 Anthropic 提供;Agent SDK 运行在开发者自己的进程里,沙箱要自己解决。
1.2. 基本信息卡
| 项目 | 内容 | 置信度 |
|---|---|---|
| 开发商 | Anthropic, PBC | 高(官方) |
| 首次发布 | 2025-05-22,以 Claude Code SDK 之名随 Claude 4 系列发布 | 中高(官方博客 + 二手时间线) |
| 更名 | 2025-09(Claude Code SDK 更名为 Claude Agent SDK) | 中高 |
| 支持语言 | Python、TypeScript;其他语言需以 CLI 子进程 + --output-format json 驱动 | 高(官方文档) |
| 开源形态 | 源码公开;整体受 Anthropic 商业条款约束,个别组件按各自 LICENSE 执行 | 中高(官方文档「License and terms」段) |
| 许可证(精确口径) | 第三方目录站标注 Python 包为 MIT、TypeScript 包为 Anthropic Commercial Terms;各包实际许可证以仓库 LICENSE 文件为准,此处标 | 低—中 |
| SDK 定价 | SDK 本身不单独收费;成本来自 Anthropic API 的 token 消耗 | 高(官方) |
| 可运行环境 | 开发者自有进程;可通过 Bedrock / Vertex AI / Azure AI Foundry 路由模型调用 | 高(官方与第三方一致) |
| 最新版本 | (版本号随发布节奏快速变化,检索日期 2026-09-12) | 缺口 |
1.3. 发展时间线
| 时间 | 事件 | 来源等级 |
|---|---|---|
| 2024-11-25 | MCP 由 Anthropic 开源发布 | A(官方) |
| 2025-02-24 | Claude Code 以 limited research preview 形式发布 | A(官方) |
| 2025-05-22 | Claude Code SDK 发布,面向 CI/CD 无头场景 | B |
| 2025-09-29 | 更名为 Claude Agent SDK,适用范围从编码扩展到通用智能体 | B |
| 2025-10-16 | Anthropic Agent Skills 发布;SKILL.md + 渐进式披露 | A(官方) |
| 2025-12-18 | Agent Skills 转为开放标准 | A(官方) |
| 2025-12 | Anthropic 参与发起 Agentic AI Foundation(Linux Foundation 旗下) | A(官方) |
1.4. 在 AI Harness 体系中的位置
按参数卡的边界表,Claude Agent SDK 既不是纯粹的 Agent Framework,也不是 Agent Platform,而是厂商提供的 Harness 参考实现:
- 它覆盖了 L1~L4 的大部分,并提供了 L6 的强原语(权限模式、Hooks 拦截、预算上限);
- 它没有内置 L5(评估与观测)与多租户治理,这两层要由宿主系统补齐;
- 它不提供 UI、租户与计费,因此不构成 Agent Platform。
这也是它最容易被误读的地方:开发者常把「装了 Agent SDK」等同于「有了 Harness」,实际上 SDK 只提供底盘,评估集、回归与审计仍需自建。
2. 名词解释
| 术语 | 英文/缩写 | 释义 | |
|---|---|---|---|
| Agent SDK | Claude Agent SDK | Anthropic 官方智能体运行时库,把 Claude Code 的工具、循环与上下文管理以库的形式暴露给 Python / TypeScript 程序 | |
| Agent Loop | Agent Loop | 「接收输入 → 评估并响应 → 执行工具 → 回灌结果 → 重复」的循环,直到模型输出中不再包含工具调用为止 | |
| Built-in Tool | Built-in Tools | SDK 自带的工具集:Read / Write / Edit / Bash / Glob / Grep / WebSearch / WebFetch 等,无需开发者实现 | |
| Subagent | Subagent | 由主智能体通过 Agent 工具派生的子智能体,拥有独立上下文窗口,中间过程不污染主上下文,只回传最终结果 | |
| Hook | Hooks | 在智能体生命周期关键点触发的回调,可拦截、阻断、改写工具调用,如 PreToolUse、PostToolUse、Stop、SessionStart | |
| Matcher | Matcher | Hook 的过滤模式(如 `Write\ | Edit`),只有命中的事件才触发对应回调 |
| Permission Mode | Permission Mode | 权限模式,控制哪些工具自动执行、哪些需要人工确认;已知模式包括 default、dontAsk、acceptEdits、bypassPermissions、plan 等 | |
| canUseTool | canUseTool | 宿主提供的审批回调,执行在该回调返回决策前暂停,可用于实现人工审批队列 | |
| Session | Session | 一次智能体会话,以 JSONL 形式持久化在本地(默认位于 ~/.claude/projects/),可恢复、继续或分叉 | |
| Resume / Fork | Resume / Fork | 基于已有 session id 恢复上下文;Fork 则从某一节点分叉出新的执行路径 | |
| Context Compaction | Compact | 上下文压缩:接近 token 上限时自动摘要早期对话轮次,保留关键信息 | |
| MCP | Model Context Protocol | 模型上下文协议,SDK 支持 stdio、HTTP/SSE 与进程内 SDK MCP 服务器三种传输 | |
| Skill | Agent Skills | 以 SKILL.md 为核心的能力包,采用三层渐进式披露:会话启动只加载 name + description,命中时加载全文,按需读取 scripts / references / assets | |
| Plugin | Plugins | 把 Skills、Subagents、Hooks 与 MCP 服务器打包、按本地路径加载的封装单元 | |
| max_turns | max_turns | 单次运行的最大轮次上限,防止智能体无限循环 | |
| max_budget_usd | max_budget_usd | 单次运行的美元预算上限,超限时智能体停止,是成本护栏的核心参数 | |
| Managed Agents | Managed Agents | Anthropic 托管的 REST API 产品,与 Agent SDK 是不同产品,沙箱由 Anthropic 运行 |
3. 功能说明
3.1. 内置工具集
SDK 出厂即带一套文件与检索工具,开发者通过 allowed_tools 白名单决定智能体可见范围:
| 工具 | 作用 | Harness 层归属 |
|---|---|---|
| Read | 读取任意文件 | L2 |
| Write | 创建新文件 | L2 |
| Edit | 对已有文件做精确编辑 | L2 |
| Bash | 执行终端命令、脚本、git 操作 | L2 |
| Glob | 按模式匹配查找文件 | L1 / L2 |
| Grep | 正则检索文件内容 | L1 / L2 |
| WebSearch | 联网检索 | L2 |
| WebFetch | 抓取并解析网页 | L2 |
| Agent | 派生子智能体 | L3 |
| Skill | 调用已注册的 Skill | L1 / L2 |
只读场景可显式配置为 ["Read", "Glob", "Grep"],智能体无法越出该列表。这种「白名单即能力边界」的设计,是 L2 与 L6 的交汇点。
3.2. Hooks 事件机制
Hooks 是 SDK 中最具 Harness 特征的设计——它把「拦截点」做成了一等公民。典型事件如下:
| 事件 | 触发时机 | 典型用途 | 语言可用性 |
|---|---|---|---|
| PreToolUse | 工具调用请求发出前 | 阻断危险命令、改写入参、注入上下文 | Python / TypeScript |
| PostToolUse | 工具执行完成 | 审计日志、结果清洗 | Python / TypeScript |
| PostToolUseFailure | 工具执行失败 | 错误兜底与重试策略 | Python / TypeScript |
| PostToolBatch | 一批工具调用全部返回、下一次模型调用前 | 一次性注入约定 | 仅 TypeScript |
| UserPromptSubmit | 用户提示词提交 | 补充上下文、合规过滤 | Python / TypeScript |
| UserPromptExpansion | 用户命令或 MCP 提示词展开为提示词前 | 阻断特定命令 | 仅 TypeScript |
| Stop | 执行结束 | 收尾、状态清理、通知 | Python / TypeScript |
| SubagentStart / SubagentStop | 子智能体启停 | 上下文准备与结果处理 | Python / TypeScript |
回调返回一个决策对象,可表达四种意图:放行、阻断、改写输入、注入上下文。例:用 PreToolUse + matcher Write|Edit 拦截对 .env 文件的写入,返回 permissionDecision: "deny"。
3.3. 权限与审批
SDK 的权限判定是一条有序链路:Hooks → deny 规则 → 权限模式 → allow 规则 → canUseTool 回调。这条顺序很重要,因为它意味着:
- Hooks 拥有最高优先级,可以硬阻断;
canUseTool位于最后,是兜底的人工审批位,可无限期挂起等待决策;- 权限模式是粗粒度开关,allow / deny 规则是中粒度,
canUseTool是细粒度。
三层叠加,构成了 L6 治理层在本平台上的主要实现形式。
3.4. 会话、子智能体与上下文管理
三个机制共同解决「长任务」问题:
- Session 持久化:会话以 JSONL 落盘,携带完整的文件读取历史、对话上下文与已完成的推理;通过
resume传回 session id 即可续跑,避免重复读取。 - Subagent 隔离:子智能体上下文全新开始,中间工具调用留在子智能体内部,只回传一条最终消息。这是 L1 层最有效的「上下文隔离」手段。
- Context Compaction:接近 token 上限时自动摘要早期轮次。
三者组合后的效果是:主上下文长度近似恒定,任务长度可以远大于上下文窗口。
3.5. MCP 与 Skills 扩展
- MCP:SDK 支持三种传输——stdio 子进程、HTTP/SSE 远程服务、进程内 SDK MCP 服务器。自定义工具可以直接实现为进程内 MCP 服务器,无需额外进程。
- Skills:以目录 +
SKILL.md组织,YAML frontmatter 必含name与description。渐进式披露把「能力描述」与「能力实现」分离,使得挂载几十个 Skill 的成本接近于挂载几个。
3.6. 预算与运行约束
| 约束参数 | 作用 | 缺失后果 |
|---|---|---|
max_turns | 限制最大轮次 | 智能体可能陷入工具调用死循环 |
max_budget_usd | 限制美元预算 | 失控智能体产生不可预期账单 |
effort | 控制推理力度 | 成本与质量无法按任务分级 |
permission_mode | 粗粒度权限开关 | 高危操作自动执行 |
allowed_tools | 工具白名单 | 能力边界不可控 |
4. 平台架构
图 4-1|Claude Agent SDK 四层架构(宿主 × SDK × 执行面 × 模型后端)
数据来源:基于本文分析绘制的示意图。
4.1. 分层架构
┌──────────────────────────────────────────────────────────┐
│ 宿主应用(你自己的进程) │
│ - 任务编排 / 队列 / 多租户 / 计费 │
│ - canUseTool 审批回调 │
└──────────────────────────────────────────────────────────┘
│
┌──────────────────────────────────────────────────────────┐
│ Claude Agent SDK │
│ query() / ClaudeSDKClient │
│ ├─ Agent Loop(接收 → 评估 → 执行工具 → 回灌 → 重复) │
│ ├─ Context Manager(Compaction / Subagent 隔离) │
│ ├─ Permission Engine(Hooks → deny → mode → allow → 回调)│
│ ├─ Session Store(JSONL 落盘,resume / fork) │
│ └─ Extension Loader(MCP / Skills / Plugins / Commands) │
└──────────────────────────────────────────────────────────┘
│
┌──────────────────────────────────────────────────────────┐
│ 执行面 │
│ - Built-in Tools(Read/Write/Edit/Bash/Glob/Grep/...) │
│ - MCP Servers(stdio / HTTP / in-process) │
│ - 外部沙箱(需宿主自备:Docker / 容器 / 受限用户) │
└──────────────────────────────────────────────────────────┘
│
┌──────────────────────────────────────────────────────────┐
│ 模型后端 │
│ Anthropic API / Bedrock / Vertex AI / Azure AI Foundry │
└──────────────────────────────────────────────────────────┘ 4.2. 一次 query 的完整生命周期
- 初始化:SDK 返回
SystemMessage(init子类型)并携带session_id。 - 提示词处理:
UserPromptSubmit钩子触发,可注入或过滤上下文。 - 模型推理:模型返回
ThinkingBlock与 / 或ToolUseBlock。 - 工具前拦截:
PreToolUse钩子按 matcher 匹配,返回放行 / 阻断 / 改写。 - 权限判定:Hooks → deny → 权限模式 → allow →
canUseTool。 - 工具执行:执行结果以
ToolResultBlock回灌为UserMessage。 - 循环:回到第 3 步,直到模型输出不含工具调用。
- 收尾:
Stop钩子触发,返回ResultMessage。
4.3. 与 CLI / Client SDK / Managed Agents 的边界
| 维度 | Agent SDK | Claude Code CLI | Client SDK | Managed Agents |
|---|---|---|---|---|
| 形态 | 库 | 终端命令 | 库 | REST API |
| 运行位置 | 你的进程 | 本地终端 | 你的进程 | Anthropic 托管 |
| 工具循环 | SDK 管理 | CLI 内部管理 | 开发者自写 | Anthropic 管理 |
| 内置工具 | 有 | 有 | 无 | 有 |
| MCP | 支持 | 支持 | 不支持 | 支持 |
| Subagents | 支持 | 支持 | 不支持 | 支持 |
| Hooks | 支持 | 支持 | 不支持 | 不支持 |
| 沙箱 | 需自备 | 需自备 | 需自备 | Anthropic 提供 |
| 典型场景 | 自动化流水线 / CI | 交互式开发 | 完全自定义 | 无服务器生产部署 |
5. Harness 设计
5.1. 六层能力总览
| 层 | 名称 | 本平台实现强度 | 判断依据 |
|---|---|---|---|
| L1 | 上下文工程 | 强 | Compaction + Subagent 隔离 + Skills 渐进披露 + 文件系统即上下文 |
| L2 | 工具与执行 | 强(执行)/ 弱(隔离) | 内置工具与 MCP 完备;无内置沙箱,容器隔离需宿主自备 |
| L3 | 编排与控制 | 中强 | 循环 + 子智能体 + 会话 resume/fork;无显式图 / DAG 原语 |
| L4 | 记忆与状态 | 中强 | JSONL 会话持久化、resume/fork、检查点回退;长期记忆依赖文件,非结构化 |
| L5 | 评估与观测 | 弱 | 无内置 Eval Set / Golden Dataset;轨迹需靠 Hooks 自行导出 |
| L6 | 治理与安全 | 强(机制)/ 中(体系) | 权限链路 + Hooks 阻断 + 预算上限齐备;无内建 RBAC / 多租户 / 合规报表 |
5.2. L1 上下文工程层
Claude Agent SDK 在 L1 上的设计可归纳为四条原则:
- 文件系统即上下文:大对象不进上下文窗口,只把路径与摘要放进上下文,需要时再读。这是「MCP-as-Code-API」思路的延伸——中间数据留在执行环境而非上下文窗口。
- 子智能体即隔离单元:把探索性、高噪声的检索工作下沉到子智能体,主上下文只接收结论。
- 渐进式披露:Skills 只在会话启动时加载
name+description,命中才加载全文,按需再读脚本与参考文件。 - 压缩兜底:接近上限时自动摘要早期轮次。
代价是:压缩与隔离都会丢失细节。这也是本平台在 L1 上唯一的负面项——上下文策略越激进,可追溯性越弱。
5.3. L2 工具与执行层
- 工具注册:内置工具 + 自定义进程内 MCP 服务器 + 外部 MCP 服务器(stdio / HTTP)。
- 调用形态:串行为主,批处理由
PostToolBatch暗示存在批量调用语义。 - 执行隔离:明确缺失。官方文档口径是 SDK 不提供容器隔离,智能体默认可访问宿主文件系统;若要生产安全,需自行加 Docker 或等价隔离。
这一条是选型时最容易被忽略的风险点:SDK 的「能力很强」与「默认不安全」是同一枚硬币的两面。
5.4. L3 编排与控制层
本节的判断是:Claude Agent SDK 在 L3 上属于「隐式编排」,与 LangGraph 的「显式编排」构成同一根轴的两端。
具体表现:
- 控制流由模型在循环内自主决定,开发者不写图、不写状态机;
- 可用的结构化手段只有三种:子智能体派生、Hooks 拦截、会话 resume/fork;
- 没有 DAG、没有条件分支原语、没有并行编排器(并行靠一次提示词里派生多个子智能体实现)。
灵活性 ↔ 可预测性的张力在此处最尖锐:
- 换来的灵活性:无需预先枚举路径,适应开放式任务;
- 付出的可预测性:同一输入两次运行可能走不同路径,无法在代码层面对「执行顺序」做回归断言。
对应的工程补偿是:把不可预测性关进 Hooks 与权限链路里——不控制「走哪条路」,而是控制「哪些路不许走」。这是本平台给出的一种有代表性的答案。
5.5. L4 记忆与状态层
| 机制 | 持久性 | 粒度 | 跨会话 |
|---|---|---|---|
| Session JSONL | 磁盘 | 完整消息流 | 是(resume / fork) |
| 文件检查点 | 磁盘 | 工作区快照 | 是 |
| Memory / CLAUDE.md | 磁盘 | 人工维护的事实条目 | 是 |
| Skills | 磁盘 | 能力包 | 是 |
优势:会话可恢复、可分叉,长任务可从崩溃点续跑。
短板:没有面向语义的长期记忆(不同于 Dify 的知识库或专门的 Memory Service),跨会话的「记住什么」仍需人工写入文件或外挂检索系统。
5.6. L5 评估与观测层
这是本平台最薄弱的一层,必须明确指出:
- 无内置 Eval Set、无 Golden Dataset、无回归集管理机制;
- 轨迹数据不自动落库,需要从
PostToolUse/Stop等 Hook 自行导出到外部观测系统; - 没有 A/B 与在线指标能力。
因此,任何以 Claude Agent SDK 为底座的生产系统,L5 必须由宿主自建。这也印证了参数卡的判断:Framework 主要覆盖 L2/L3,是 Harness 的子集——Claude Agent SDK 覆盖得比一般 Framework 更宽,但依然没有补齐 L5。
5.7. L6 治理与安全层
| 治理能力 | 实现方式 | 强度 |
|---|---|---|
| 工具准入 | allowed_tools / disallowed_tools 白黑名单 | 强 |
| 行为阻断 | Hooks 返回 deny 决策 | 强 |
| 人工审批 | canUseTool 回调挂起 | 强 |
| 粗粒度模式 | permission_mode(default / dontAsk / acceptEdits / bypassPermissions / plan 等) | 中强 |
| 成本护栏 | max_budget_usd + max_turns | 强 |
| 审计日志 | 需由 Hooks 自行写入 | 弱(需自建) |
| 身份与租户 | 无内建 RBAC / 多租户 | 缺失 |
开放性 ↔ 治理的张力在本平台表现得很清楚:MCP 让智能体可以连接任意外部系统,能力边界被打开的同时,攻击面同步被打开——恶意 MCP 服务器、提示词注入、凭据泄露都发生在这一层。SDK 给出的补偿是「Hooks 最高优先级 + 白名单 + 审批回调」三件套,但这套机制要求宿主团队自己写、自己维护,不是开箱即用的合规能力。
5.8. 三条内在张力的具体表现
| 张力 | 在本平台的体现 | 缓解手段 |
|---|---|---|
| 灵活性 ↔ 可预测性 | 隐式循环,控制流由模型决定,无显式图 | Hooks 约束「不许走什么」而非「必须走什么」;用 max_turns 限定深度 |
| 开放性 ↔ 治理 | MCP 三种传输打开互操作,也打开攻击面 | 白名单 + deny 钩子 + canUseTool 审批;沙箱外挂 |
| 成本 ↔ 深度 | 子智能体并行与长循环显著放大 token 消耗 | max_budget_usd 硬止损;Compaction 降输入成本;按任务选模型档位 |
6. 实际案例
以下案例均来自 Anthropic 官方公开工程博客,未做效果数据外推。
案例一:长时运行智能体的双智能体 Harness
Anthropic 在《Effective harnesses for long-running agents》中给出了长时运行智能体的初始方案:一个初始化智能体负责搭建环境、写初始进度文件,一个编码智能体负责按增量推进并在每轮结束时写入结构化进度。核心价值不在模型,而在Harness 把长任务切成可判定、可恢复的增量。该文同时给出了 Claude Agent SDK 的官方定位原话,是本组文档引用的定调来源。
案例二:三智能体演进
同一系列工作中,方案从双智能体演进为三智能体,增加了专门的验证 / 收尾角色。这一演进说明:当任务变长,Harness 的复杂度增长主要体现在 L3(编排)与 L5(验证)两层,而不是模型调用层。
案例三:Claude Code 作为 Agent SDK 的同源验证
Claude Code 与 Agent SDK 共用同一条 agent loop,因此 Claude Code 的公开数据可作为该 loop 工程可用性的旁证。第三方口径称 Claude Code 发布七周内达到 350,000 DAU、产生超 100 万个被合并 PR、Anthropic 内部约 1/4 的代码提交由其产生——该组数据来自二手来源,标 ,不作为结论依据。
未检索到公开量化数据的部分:截至检索日期 2026-09-12,未检索到 Anthropic 官方发布的、以 Claude Agent SDK 为底座的第三方企业落地量化效果数据(如成本下降百分比、任务成功率)。此处如实标注,不做补全。
7. 总结
7.1. 优势
- 官方定义级样本:厂商首次将 "harness" 写入产品定义,六层模型在本平台上有完整可对照物。
- L1 设计成熟:上下文压缩、子智能体隔离、渐进式披露三者组合,是长任务可行性的关键。
- L6 机制强:权限判定链路有序、Hooks 可硬阻断、预算可硬止损,是同类 SDK 中治理原语最完整的之一。
- 与 Claude Code 同源:工程验证充分,工具与循环经过大规模真实使用打磨。
- 后端可替换:支持 Bedrock / Vertex AI / Azure AI Foundry,适配既有云账本。
7.2. 劣势
- L5 缺失:无内置评估与观测,轨迹与回归集需自建。
- 无内置沙箱:生产安全需宿主自备容器隔离。
- L3 隐式:控制流不可见、不可断言,可预测性弱于显式图框架。
- 无多租户与 RBAC:不构成 Agent Platform,租户、计费、审计体系需自建。
- 成本不可预先估算:隐式循环 + 子智能体并行使单次任务成本方差大。
7.3. 适用边界
| 场景 | 是否适用 | 理由 |
|---|---|---|
| 自动化编码流水线 / CI | 适用 | 与 Claude Code 同源,工具链完备 |
| 需要人工审批的高危操作 | 适用 | canUseTool 可无限期挂起等待决策 |
| 长时研究型任务 | 适用 | 子智能体隔离 + 会话恢复 |
| 需要强可预测性的金融 / 合规流程 | 不适用 | L3 无显式图,无法做执行顺序回归 |
| 需要开箱即用评估体系的团队 | 不适用 | L5 需自建 |
| 需要多租户 SaaS 交付 | 不适用 | SDK 不提供租户与计费 |
7.4. 选型建议
- 若团队已有较强的平台工程能力,能把 L5(评估观测)与 L6 中的审计、租户部分补齐,Claude Agent SDK 是目前六层覆盖最均衡的厂商级底盘。
- 若团队首要诉求是「执行顺序可断言、可回归」,应优先考虑显式图框架(详见
04-langgraph.md)。 - 若团队首要诉求是「非工程角色也能搭智能体」,应优先考虑 Agent Platform(详见
05-dify.md、06-coze.md)。 - 无论何种选型,
max_budget_usd与max_turns必须在首次上线前配置,否则成本护栏形同虚设。
信息缺口声明
- 各包精确许可证:第三方目录站给出 "Python 包 MIT、TypeScript 包 Anthropic Commercial Terms" 的口径,但未与仓库 LICENSE 文件逐包核对,标 。
- 当前最新版本号:SDK 版本随发布节奏快速变化,检索日期 2026-09-12 未取得权威版本号,标 。
- 模型具体单价:不同第三方来源给出的 Sonnet / Opus 档位单价相互冲突,本文件只保留「SDK 免费、按 token 计费」这一确定性表述,单价标 。
- 完整 Hooks 事件清单:官方文档中事件总数存在版本差异(有来源称 27 个事件点),本文件只列出可交叉验证的主要事件。
- 第三方企业落地量化数据:未检索到以 Claude Agent SDK 为底座的公开可验证企业效果数据,未做任何补全。
- Managed Agents 的功能边界:与 Agent SDK 为不同产品,本次未做专项检索,其定价与配额标 。
8. 参考资料
- Effective harnesses for long-running agents — Anthropic Engineering, 2025。https://www.anthropic.com/engineering/effective-harnesses-for-long-running-agents
- Agent SDK overview — Anthropic(Claude Code Docs)。https://platform.claude.com/docs/en/agent-sdk/overview
- Intercept and control agent behavior with hooks — Anthropic(Claude Code Docs)。https://code.claude.com/docs/en/agent-sdk/hooks
- Equipping agents for the real world with Agent Skills — Anthropic Engineering, 2025。https://www.anthropic.com/engineering/equipping-agents-for-the-real-world-with-agent-skills
- Claude Agent SDK — Agent Patterns Catalog(组件清单与许可口径)。https://www.agentpatternscatalog.org/compositions/claude-agent-sdk
- Claude Agent SDK — Anthropic's Framework for Production AI Agents — Cybernauten。https://cybernauten.com/tools/claude-agent-sdk
- Claude Agent SDK: Features, Pricing & Alternatives — AI Coolies。https://aicoolies.com/tools/claude-agent-sdk
- New tools for building agents — OpenAI(作为同期编排层官方化的对照)。https://openai.com/blog/new-tools-for-building-agents
- R01-概述检索报告(Harness 定义、MCP 时间线、Skills 发布节点)— 本项目内部检索报告。
- 项目参数卡 v1.0(六层能力模型与概念边界)— 本项目内部基准文件。
Claude Agent SDK(Anthropic)
1. Introduction
1.1. Platform Positioning and Origin
Claude Agent SDK is the agent runtime library officially provided by Anthropic, used to embed the Claude Code tooling of "tools + agent loop + context management" programmatically into a developer's own process, with language coverage of Python and TypeScript. Here is the exact positioning statement from Anthropic's official engineering blog:
"The Claude Agent SDK is a powerful, general-purpose agent harness adept at coding, as well as other tasks that require the model to use tools to gather context, plan, and execute."
This statement is of tone-setting significance throughout the entire AI Harness research: it is the first time a leading model vendor wrote the word "harness" into a product definition, rather than treating it as an internal implementation jargon. It confirms the core judgment in the parameter card — Harness is not responsible for improving model intelligence, but for transforming the model's uncertainty into engineering predictability.
It is worth emphasizing the SDK's three boundaries:
- Boundary with Claude Code CLI: the CLI is a human-in-the-loop terminal tool, while the SDK is a program-in-the-loop programming library; both run on the same agent loop.
- Boundary with Anthropic Client SDK: the Client SDK exposes only the Messages API, so the tool loop must be written by the developer; the Agent SDK builds in the tool loop, permissions, compaction, and sessions entirely.
- Boundary with Managed Agents: Managed Agents is a REST API product hosted by Anthropic, with the sandbox provided by Anthropic; the Agent SDK runs in the developer's own process, so the sandbox must be solved by the developer.
1.2. Basic Information Card
| Item | Content | Confidence |
|---|---|---|
| Developer | Anthropic, PBC | High (official) |
| First release | 2025-05-22, released under the name Claude Code SDK alongside the Claude 4 series | Medium-high (official blog + secondary timeline) |
| Rename | 2025-09 (Claude Code SDK renamed to Claude Agent SDK) | Medium-high |
| Supported languages | Python, TypeScript; other languages must be driven via CLI subprocess + --output-format json | High (official docs) |
| Open-source form | Source code is public; overall subject to Anthropic's commercial terms, individual components follow their respective LICENSE | Medium-high (official docs, "License and terms" section) |
| License (precise) | Third-party directory sites mark the Python package as MIT and the TypeScript package as Anthropic Commercial Terms; the actual license of each package is governed by the repository LICENSE file, marked here as [To be verified] | Low-medium |
| SDK pricing | The SDK itself is not charged separately; cost comes from Anthropic API token consumption | High (official) |
| Runnable environment | Developer's own process; model calls can be routed via Bedrock / Vertex AI / Azure AI Foundry | High (official and third-party agree) |
| Latest version | (version number changes rapidly with the release cadence, search date 2026-09-12) | Gap |
1.3. Development Timeline
| Date | Event | Source level |
|---|---|---|
| 2024-11-25 | MCP released as open source by Anthropic | A (official) |
| 2025-02-24 | Claude Code released as a limited research preview | A (official) |
| 2025-05-22 | Claude Code SDK released, aimed at headless CI/CD scenarios | B |
| 2025-09-29 | Renamed to Claude Agent SDK, scope expanded from coding to general-purpose agents | B |
| 2025-10-16 | Anthropic Agent Skills released; SKILL.md + progressive disclosure | A (official) |
| 2025-12-18 | Agent Skills became an open standard | A (official) |
| 2025-12 | Anthropic co-founded the Agentic AI Foundation (under the Linux Foundation) | A (official) |
1.4. Position in the AI Harness System
According to the boundary table in the parameter card, Claude Agent SDK is neither a pure Agent Framework nor an Agent Platform, but rather a vendor-provided Harness reference implementation:
- It covers most of L1~L4 and provides strong primitives for L6 (permission modes, Hooks interception, budget caps);
- It does not build in L5 (evaluation and observability) and multi-tenant governance; these two layers must be completed by the host system;
- It provides no UI, tenancy, or billing, and therefore does not constitute an Agent Platform.
This is also where it is most easily misread: developers often equate "installing the Agent SDK" with "having a Harness", but in reality the SDK only provides the chassis — the evaluation set, regression, and auditing still need to be self-built.
2. Glossary
| Term | English / Abbreviation | Definition | |
|---|---|---|---|
| Agent SDK | Claude Agent SDK | Anthropic's official agent runtime library, exposing Claude Code's tools, loop, and context management as a library to Python / TypeScript programs | |
| Agent Loop | Agent Loop | a loop of "receive input → evaluate and respond → execute tools → feed results back → repeat" until the model output no longer contains tool calls | |
| Built-in Tool | Built-in Tools | the tool set that ships with the SDK: Read / Write / Edit / Bash / Glob / Grep / WebSearch / WebFetch, etc., no developer implementation required | |
| Subagent | Subagent | a child agent derived by the main agent via the Agent tool, with its own context window; intermediate processes do not pollute the main context, and only the final result is returned | |
| Hook | Hooks | callbacks triggered at key points in the agent lifecycle that can intercept, block, or rewrite tool calls, such as PreToolUse, PostToolUse, Stop, SessionStart | |
| Matcher | Matcher | a filter pattern for Hooks (e.g. `Write\ | Edit`), where only matching events trigger the corresponding callback |
| Permission Mode | Permission Mode | permission mode, controlling which tools execute automatically and which require human confirmation; known modes include default, dontAsk, acceptEdits, bypassPermissions, plan, etc. | |
| canUseTool | canUseTool | the approval callback provided by the host; execution pauses until the callback returns a decision, and it can be used to implement a human approval queue | |
| Session | Session | a single agent session, persisted locally in JSONL form (by default at ~/.claude/projects/), which can be resumed, continued, or forked | |
| Resume / Fork | Resume / Fork | restore context based on an existing session id; Fork branches a new execution path from a given node | |
| Context Compaction | Compact | context compaction: when approaching the token limit, early conversation turns are automatically summarized, preserving key information | |
| MCP | Model Context Protocol | the Model Context Protocol; the SDK supports three transports: stdio, HTTP/SSE, and in-process SDK MCP servers | |
| Skill | Agent Skills | a capability package centered on SKILL.md, using three levels of progressive disclosure: only name + description are loaded at session start, the full text is loaded on a hit, and scripts / references / assets are read on demand | |
| Plugin | Plugins | a packaging unit that bundles Skills, Subagents, Hooks, and MCP servers and loads them by local path | |
| max_turns | max_turns | the maximum number of turns for a single run, preventing the agent from looping indefinitely | |
| max_budget_usd | max_budget_usd | the USD budget cap for a single run; the agent stops when the limit is exceeded, and it is the core parameter of the cost guardrail | |
| Managed Agents | Managed Agents | Anthropic's hosted REST API product, a different product from the Agent SDK, with the sandbox operated by Anthropic |
3. Features
3.1. Built-in Tool Set
The SDK ships with a set of file and retrieval tools out of the box; the developer decides the agent's visible scope through the allowed_tools allowlist:
| Tool | Function | Harness layer |
|---|---|---|
| Read | Read arbitrary files | L2 |
| Write | Create new files | L2 |
| Edit | Make precise edits to existing files | L2 |
| Bash | Execute terminal commands, scripts, and git operations | L2 |
| Glob | Find files by pattern matching | L1 / L2 |
| Grep | Search file contents by regex | L1 / L2 |
| WebSearch | Search the web | L2 |
| WebFetch | Fetch and parse web pages | L2 |
| Agent | Derive subagents | L3 |
| Skill | Invoke a registered Skill | L1 / L2 |
Read-only scenarios can be explicitly configured as ["Read", "Glob", "Grep"], and the agent cannot go beyond that list. This "allowlist-as-capability-boundary" design is the meeting point of L2 and L6.
3.2. Hooks Event Mechanism
Hooks are the most Harness-typical design in the SDK — it makes "interception points" first-class citizens. Typical events are as follows:
| Event | Trigger timing | Typical use | Language availability |
|---|---|---|---|
| PreToolUse | Before the tool call request is made | Block dangerous commands, rewrite input parameters, inject context | Python / TypeScript |
| PostToolUse | After tool execution completes | Audit logging, result cleaning | Python / TypeScript |
| PostToolUseFailure | Tool execution fails | Error fallback and retry strategies | Python / TypeScript |
| PostToolBatch | After a batch of tool calls all return, before the next model call | One-time injection convention | TypeScript only |
| UserPromptSubmit | User prompt submitted | Supplement context, compliance filtering | Python / TypeScript |
| UserPromptExpansion | Before a user command or MCP prompt is expanded into a prompt | Block specific commands | TypeScript only |
| Stop | Execution ends | Wrap-up, state cleanup, notifications | Python / TypeScript |
| SubagentStart / SubagentStop | Subagent start/stop | Context preparation and result handling | Python / TypeScript |
The callback returns a decision object that can express four intentions: allow, block, rewrite input, and inject context. For example, use PreToolUse with matcher Write|Edit to intercept writes to a .env file and return permissionDecision: "deny".
3.3. Permissions and Approval
The SDK's permission decision is an ordered chain: Hooks → deny rules → permission mode → allow rules → canUseTool callback. This order matters, because it means:
- Hooks have the highest priority and can hard-block;
canUseToolsits at the end as the fallback human-approval slot and can suspend indefinitely waiting for a decision;- permission mode is a coarse-grained switch, allow / deny rules are medium-grained, and
canUseToolis fine-grained.
The three layers stacked together constitute the main implementation form of the L6 governance layer on this platform.
3.4. Sessions, Subagents, and Context Management
Three mechanisms together solve the "long-task" problem:
- Session persistence: sessions are written to disk in JSONL, carrying the complete file-read history, conversation context, and completed reasoning; passing the session id back via
resumeresumes the run and avoids re-reading. - Subagent isolation: a subagent's context starts fresh, intermediate tool calls remain inside the subagent, and only one final message is returned. This is the most effective "context isolation" means at the L1 layer.
- Context Compaction: when approaching the token limit, early turns are automatically summarized.
The combined effect of the three is: the main context length stays approximately constant, so the task length can be far greater than the context window.
3.5. MCP and Skills Extension
- MCP: the SDK supports three transports — stdio subprocess, HTTP/SSE remote services, and in-process SDK MCP servers. Custom tools can be implemented directly as in-process MCP servers without an extra process.
- Skills: organized as a directory +
SKILL.md, with the YAML frontmatter necessarily containingnameanddescription. Progressive disclosure separates "capability description" from "capability implementation", so that mounting dozens of Skills costs about as much as mounting a few.
3.6. Budget and Runtime Constraints
| Constraint parameter | Function | Consequence if missing |
|---|---|---|
max_turns | Limit the maximum number of turns | The agent may fall into an infinite tool-call loop |
max_budget_usd | Limit the USD budget | A runaway agent produces unpredictable bills |
effort | Control reasoning effort | Cost and quality cannot be tiered by task |
permission_mode | Coarse-grained permission switch | High-risk operations execute automatically |
allowed_tools | Tool allowlist | Capability boundaries are uncontrollable |
4. Platform Architecture
图 4-1|Claude Agent SDK 四层架构(宿主 × SDK × 执行面 × 模型后端)
数据来源:基于本文分析绘制的示意图。
4.1. Layered Architecture
┌──────────────────────────────────────────────────────────┐
│ 宿主应用(你自己的进程) │
│ - 任务编排 / 队列 / 多租户 / 计费 │
│ - canUseTool 审批回调 │
└──────────────────────────────────────────────────────────┘
│
┌──────────────────────────────────────────────────────────┐
│ Claude Agent SDK │
│ query() / ClaudeSDKClient │
│ ├─ Agent Loop(接收 → 评估 → 执行工具 → 回灌 → 重复) │
│ ├─ Context Manager(Compaction / Subagent 隔离) │
│ ├─ Permission Engine(Hooks → deny → mode → allow → 回调)│
│ ├─ Session Store(JSONL 落盘,resume / fork) │
│ └─ Extension Loader(MCP / Skills / Plugins / Commands) │
└──────────────────────────────────────────────────────────┘
│
┌──────────────────────────────────────────────────────────┐
│ 执行面 │
│ - Built-in Tools(Read/Write/Edit/Bash/Glob/Grep/...) │
│ - MCP Servers(stdio / HTTP / in-process) │
│ - 外部沙箱(需宿主自备:Docker / 容器 / 受限用户) │
└──────────────────────────────────────────────────────────┘
│
┌──────────────────────────────────────────────────────────┐
│ 模型后端 │
│ Anthropic API / Bedrock / Vertex AI / Azure AI Foundry │
└──────────────────────────────────────────────────────────┘ 4.2. Complete Lifecycle of a Single Query
- Initialization: the SDK returns a
SystemMessage(of theinitsubtype) carrying thesession_id. - Prompt processing: the
UserPromptSubmithook fires, allowing context to be injected or filtered. - Model reasoning: the model returns a
ThinkingBlockand / or aToolUseBlock. - Pre-tool interception: the
PreToolUsehook matches by matcher and returns allow / block / rewrite. - Permission decision: Hooks → deny → permission mode → allow →
canUseTool. - Tool execution: the execution result is fed back as a
UserMessageviaToolResultBlock. - Loop: return to step 3 until the model output contains no tool calls.
- Wrap-up: the
Stophook fires and aResultMessageis returned.
4.3. Boundaries with CLI / Client SDK / Managed Agents
| Dimension | Agent SDK | Claude Code CLI | Client SDK | Managed Agents |
|---|---|---|---|---|
| Form | Library | Terminal command | Library | REST API |
| Runtime location | Your process | Local terminal | Your process | Anthropic-hosted |
| Tool loop | Managed by the SDK | Managed internally by the CLI | Written by the developer | Managed by Anthropic |
| Built-in tools | Yes | Yes | No | Yes |
| MCP | Supported | Supported | Not supported | Supported |
| Subagents | Supported | Supported | Not supported | Supported |
| Hooks | Supported | Supported | Not supported | Not supported |
| Sandbox | Must be self-provided | Must be self-provided | Must be self-provided | Provided by Anthropic |
| Typical scenario | Automated pipeline / CI | Interactive development | Fully custom | Serverless production deployment |
5. Harness Design
5.1. Overview of the Six-Layer Capabilities
| Layer | Name | Implementation strength on this platform | Basis for judgment |
|---|---|---|---|
| L1 | Context engineering | Strong | Compaction + Subagent isolation + Skills progressive disclosure + filesystem-as-context |
| L2 | Tools and execution | Strong (execution) / Weak (isolation) | Built-in tools and MCP are complete; no built-in sandbox, container isolation must be self-provided by the host |
| L3 | Orchestration and control | Medium-strong | Loop + subagents + session resume/fork; no explicit graph / DAG primitives |
| L4 | Memory and state | Medium-strong | JSONL session persistence, resume/fork, checkpoint rollback; long-term memory depends on files, unstructured |
| L5 | Evaluation and observability | Weak | No built-in Eval Set / Golden Dataset; traces must be exported manually via Hooks |
| L6 | Governance and security | Strong (mechanisms) / Medium (system) | Permission chain + Hooks blocking + budget caps are all in place; no built-in RBAC / multi-tenancy / compliance reporting |
5.2. L1 Context Engineering Layer
Claude Agent SDK's design at L1 can be summarized into four principles:
- Filesystem-as-context: large objects do not enter the context window; only the path and summary are placed in the context, and the object is read when needed. This is an extension of the "MCP-as-Code-API" approach — intermediate data stays in the execution environment rather than the context window.
- Subagent-as-isolation-unit: exploratory, high-noise retrieval work is pushed down to subagents, and the main context only receives the conclusions.
- Progressive disclosure: Skills only load
name+descriptionat session start, load the full text on a hit, and read scripts and reference files on demand. - Compaction as fallback: when approaching the limit, early turns are automatically summarized.
The cost is that both compaction and isolation lose details. This is also the platform's only negative item at L1 — the more aggressive the context strategy, the weaker the traceability.
5.3. L2 Tools and Execution Layer
- Tool registration: built-in tools + custom in-process MCP servers + external MCP servers (stdio / HTTP).
- Call form: predominantly serial; batching is hinted at by
PostToolBatch, implying a batch-call semantic exists. - Execution isolation: explicitly absent. According to the official docs, the SDK does not provide container isolation, and the agent can access the host filesystem by default; for production safety you must add Docker or an equivalent isolation yourself.
This item is the risk point most easily overlooked during selection: the SDK's "very capable" and "not secure by default" are two sides of the same coin.
5.4. L3 Orchestration and Control Layer
The judgment of this section is: at L3, Claude Agent SDK belongs to "implicit orchestration", forming the two ends of the same axis with LangGraph's "explicit orchestration".
Concretely:
- Control flow is decided autonomously by the model within the loop; the developer writes no graphs and no state machines;
- only three structured means are available: subagent derivation, Hooks interception, and session resume/fork;
- there is no DAG, no conditional-branch primitive, and no parallel orchestrator (parallelism is achieved by deriving multiple subagents in a single prompt).
The flexibility ↔ predictability tension is sharpest here:
- the flexibility gained: no need to enumerate paths in advance, adapting to open-ended tasks;
- the predictability paid: the same input may take different paths across two runs, making it impossible to assert "execution order" regressions at the code level.
The corresponding engineering compensation is to confine unpredictability within Hooks and the permission chain — not to control "which way to go", but to control "which ways are forbidden". This is one representative answer offered by this platform.
5.5. L4 Memory and State Layer
| Mechanism | Persistence | Granularity | Cross-session |
|---|---|---|---|
| Session JSONL | Disk | Full message stream | Yes (resume / fork) |
| File checkpoints | Disk | Workspace snapshot | Yes |
| Memory / CLAUDE.md | Disk | Manually maintained fact entries | Yes |
| Skills | Disk | Capability packages | Yes |
Strengths: sessions can be resumed and forked, so long tasks can continue from the point of a crash.
Weaknesses: there is no semantic-oriented long-term memory (unlike Dify's knowledge base or a dedicated Memory Service); across sessions, "what to remember" still requires manual writing to files or an external retrieval system.
5.6. L5 Evaluation and Observability Layer
This is the weakest layer of the platform, and it must be clearly stated:
- no built-in Eval Set, no Golden Dataset, no regression-set management mechanism;
- trace data is not automatically persisted; it must be exported manually to an external observability system via Hooks such as
PostToolUse/Stop; - no A/B or online-metric capabilities.
Therefore, any production system built on Claude Agent SDK must have L5 self-built by the host. This also confirms the judgment in the parameter card: a Framework mainly covers L2/L3 and is a subset of a Harness — Claude Agent SDK covers wider than a typical Framework, yet still does not complete L5.
5.7. L6 Governance and Security Layer
| Governance capability | Implementation | Strength |
|---|---|---|
| Tool admission | allowed_tools / disallowed_tools allow/deny lists | Strong |
| Behavior blocking | Hooks returning a deny decision | Strong |
| Human approval | canUseTool callback suspension | Strong |
| Coarse-grained mode | permission_mode (default / dontAsk / acceptEdits / bypassPermissions / plan, etc.) | Medium-strong |
| Cost guardrail | max_budget_usd + max_turns | Strong |
| Audit log | Must be written manually via Hooks | Weak (needs self-building) |
| Identity and tenancy | No built-in RBAC / multi-tenancy | Absent |
The openness ↔ governance tension is very clear on this platform: MCP lets an agent connect to any external system — as the capability boundary opens, the attack surface opens at the same time; malicious MCP servers, prompt injection, and credential leakage all happen at this layer. The compensation the SDK offers is the trio of "Hooks highest priority + allowlist + approval callback", but this mechanism requires the host team to write and maintain it themselves; it is not an out-of-the-box compliance capability.
5.8. Concrete Manifestations of the Three Intrinsic Tensions
| Tension | Manifestation on this platform | Mitigation |
|---|---|---|
| Flexibility ↔ predictability | Implicit loop, control flow decided by the model, no explicit graph | Hooks constrain "what is not allowed" rather than "what must be done"; use max_turns to bound depth |
| Openness ↔ governance | MCP's three transports open interoperability but also the attack surface | Allowlist + deny hooks + canUseTool approval; sandbox externally mounted |
| Cost ↔ depth | Subagent parallelism and long loops significantly amplify token consumption | max_budget_usd as a hard stop; Compaction to lower input cost; pick a model tier per task |
6. Real-World Examples
The following cases all come from Anthropic's official public engineering blog, with no extrapolation of effect data.
Case One: A two-agent Harness for long-running agents
In Effective harnesses for long-running agents, Anthropic presented an initial design for long-running agents: one initializer agent is responsible for setting up the environment and writing the initial progress file, and one coding agent is responsible for advancing in increments and writing structured progress at the end of each round. The core value lies not in the model, but in the Harness cutting a long task into decidable, resumable increments. The article also gives the official positioning statement of the Claude Agent SDK, which serves as the tone-setting source cited by this group of documents.
Case Two: The three-agent evolution
In the same series of work, the design evolved from two agents to three, adding a dedicated verification / wrap-up role. This evolution shows that: as the task grows longer, the growth in Harness complexity is mainly reflected in the L3 (orchestration) and L5 (verification) layers, not the model-call layer.
Case Three: Claude Code as a same-origin validation of the Agent SDK
Claude Code and the Agent SDK share the same agent loop, so Claude Code's public data can serve as supporting evidence for the engineering usability of that loop. Third-party sources claim that within seven weeks of its release Claude Code reached 350,000 DAU, produced more than 1 million merged PRs, and generated about 1/4 of Anthropic's internal code commits — this set of data comes from secondary sources, is marked [To be verified], and is not used as a basis for conclusions.
Part for which no public quantified data was found: as of the search date 2026-09-12, no third-party enterprise adoption data with quantified effects (such as cost-reduction percentages or task success rates) officially published by Anthropic and built on the Claude Agent SDK could be found. This is stated truthfully here, with no attempt to fill the gap.
7. Summary
7.1. Strengths
- An officially defining sample: the vendor wrote "harness" into the product definition for the first time, and the six-layer model has a complete, comparable counterpart on this platform.
- Mature L1 design: the combination of context compaction, subagent isolation, and progressive disclosure is key to the feasibility of long tasks.
- Strong L6 mechanisms: the permission-decision chain is ordered, Hooks can hard-block, and the budget has a hard stop — among the most complete governance primitives in similar SDKs.
- Same origin as Claude Code: engineering validation is ample, and the tools and loop are refined through large-scale real-world use.
- Replaceable backends: supports Bedrock / Vertex AI / Azure AI Foundry, fitting existing cloud cost ledgers.
7.2. Weaknesses
- L5 is missing: there is no built-in evaluation or observability, and traces and regression sets must be self-built.
- No built-in sandbox: production safety requires the host to provide container isolation.
- Implicit L3: control flow is invisible and non-assertable, and predictability is weaker than in explicit-graph frameworks.
- No multi-tenancy or RBAC: it does not constitute an Agent Platform, so the tenancy, billing, and audit systems must be self-built.
- Cost cannot be estimated in advance: the implicit loop plus subagent parallelism makes the cost variance of a single task large.
7.3. Applicability Scope
| Scenario | Applicable? | Reason |
|---|---|---|
| Automated coding pipelines / CI | Applicable | Same origin as Claude Code, complete toolchain |
| High-risk operations requiring human approval | Applicable | canUseTool can suspend indefinitely waiting for a decision |
| Long-duration research-type tasks | Applicable | Subagent isolation + session resumption |
| Financial / compliance processes requiring strong predictability | Not applicable | L3 has no explicit graph, so execution-order regression is impossible |
| Teams needing an out-of-the-box evaluation system | Not applicable | L5 must be self-built |
| Multi-tenant SaaS delivery | Not applicable | The SDK does not provide tenancy or billing |
7.4. Selection Recommendations
- If the team already has strong platform-engineering capabilities and can complete L5 (evaluation and observability) and the audit / tenancy parts of L6, Claude Agent SDK is currently the vendor-grade chassis with the most well-balanced six-layer coverage.
- If the team's primary requirement is "execution order must be assertable and regressable", explicit-graph frameworks should be preferred (see
04-langgraph.md). - If the team's primary requirement is "non-engineering roles can also build agents", an Agent Platform should be preferred (see
05-dify.md,06-coze.md). - Regardless of the choice,
max_budget_usdandmax_turnsmust be configured before the first launch; otherwise, the cost guardrail is nothing but a formality.
Information Gap Statement
- Exact license of each package: third-party directory sites give the statement "Python package MIT, TypeScript package Anthropic Commercial Terms", but it has not been checked package by package against the repository LICENSE file; marked
[To be verified]. - Current latest version number: the SDK version changes rapidly with the release cadence; no authoritative version number was obtained as of the search date 2026-09-12; marked
[To be verified]. - Specific model unit prices: unit prices given by different third-party sources for the Sonnet / Opus tiers conflict with each other; this document only retains the definitive statement "SDK is free, billed by token", and the unit price is marked
[To be verified]. - Complete list of Hooks events: the total number of events differs across versions of the official docs (one source cites 27 event points); this document only lists the major events that can be cross-validated.
- Third-party enterprise adoption quantified data: no publicly verifiable enterprise-effect data built on the Claude Agent SDK was found, and no attempt was made to fill the gap.
- Functional boundary of Managed Agents: it is a different product from the Agent SDK; no dedicated search was done this time, and its pricing and quotas are marked
[To be verified].
8. References
- Effective harnesses for long-running agents — Anthropic Engineering, 2025. https://www.anthropic.com/engineering/effective-harnesses-for-long-running-agents
- Agent SDK overview — Anthropic (Claude Code Docs). https://platform.claude.com/docs/en/agent-sdk/overview
- Intercept and control agent behavior with hooks — Anthropic (Claude Code Docs). https://code.claude.com/docs/en/agent-sdk/hooks
- Equipping agents for the real world with Agent Skills — Anthropic Engineering, 2025. https://www.anthropic.com/engineering/equipping-agents-for-the-real-world-with-agent-skills
- Claude Agent SDK — Agent Patterns Catalog (component list and licensing terms). https://www.agentpatternscatalog.org/compositions/claude-agent-sdk
- Claude Agent SDK — Anthropic's Framework for Production AI Agents — Cybernauten. https://cybernauten.com/tools/claude-agent-sdk
- Claude Agent SDK: Features, Pricing & Alternatives — AI Coolies. https://aicoolies.com/tools/claude-agent-sdk
- New tools for building agents — OpenAI (as a contemporaneous reference for the formalization of the orchestration layer). https://openai.com/blog/new-tools-for-building-agents
- R01-Overview research report (Harness definition, MCP timeline, Skills release milestones) — this project's internal research report.
- Project parameter card v1.0 (six-layer capability model and conceptual boundaries) — this project's internal baseline document.