心 智 七 篇 · Seven Mental Models
← Knowledge Atlas · 源头

Building Agents with the Claude Agent SDK

Claude Agent SDK 设计哲学:给 agent 一台计算机,隐式循环架构,gather-act-verify-repeat
来源 · CLAUDE AGENT SDK · Thariq Shihipar · Give Claude a Computer · 隐式循环

Building Agents with the Claude Agent SDK

Thariq Shihipar(Anthropic)——Claude Agent SDK 设计哲学:给 agent 一台计算机

核心设计原则:「Give Claude a Computer」——程序员需要什么工具,Claude 就需要什么工具。Agent 在 gather context → take action → verify work → repeat 的反馈循环中运行——不是预定义的图结构,而是模型自主决定下一步:隐式循环架构。

Agent 能力三层
1. Gather Context(获取上下文)
Agentic search:文件系统结构 + bash(文件夹结构是 context engineering 的一种形式)Subagents:并行化 + context 隔离,只返回相关信息给 orchestratorCompaction:context 接近上限时自动压缩历史
2. Take Action(执行操作)
Tools:agent 的主要执行构件,在 context 中占据显著位置影响模型决策Bash & scripts + Code generation + MCP 外部服务集成
3. Verify Work(验证工作)
Rules-based(lint)→ Visual feedback(截图多模态)→ LLM-as-judge
设计原则
Semantic vs Agentic Search
语义检索快但不透明;先用 agentic search,它更准确且维护成本低
Tool 设计如写文档
工具定义要像给初级开发者写的文档——ACI 与 HCI 同等重要
→ Implicit Loop Architecture · Claude Agent SDK · Context ManagementAnthropic Engineering Blog

Building Agents with the Claude Agent SDK

概述

本文介绍 Claude Agent SDK(原 Claude Code SDK)的设计哲学和使用方法。核心主张:给 agent 一台计算机——让它像人类一样使用文件系统、终端、工具来完成工作。

核心设计原则

”Give Claude a computer”

Claude Code 的关键设计原则:程序员需要什么工具,Claude 就需要什么工具——查找文件、编辑文件、lint、运行、调试、迭代。通过给 Claude 访问终端的能力,它可以像程序员一样写代码,也可以做非编码任务(读 CSV、搜索网络、构建可视化、解读指标)。

隐式循环架构

Agent 在一个反馈循环中运行:gather context → take action → verify work → repeat。这不是预定义的图结构,而是模型自主决定下一步——隐式循环

Agent 能力三层

1. Gather Context(获取上下文)

  • Agentic search:利用文件系统结构 + bash 工具(grep、tail)按需拉取信息,文件夹结构本身就是 context engineering 的一种形式
  • Semantic search:比 agentic search 快但准确性低、维护成本高、不透明,建议先用 agentic search
  • Subagents:并行化 + context 隔离,只返回相关信息给 orchestrator
  • Compaction:context 接近上限时自动压缩历史

2. Take Action(执行操作)

  • Tools:agent 的主要执行构件,在 context window 中占据显著位置,影响模型决策
  • Bash & scripts:通用计算能力,处理非结构化任务
  • Code generation:代码是精确、可组合、可复用的输出形式
  • MCP:标准化外部服务集成,免去自定义集成代码

3. Verify Work(验证工作)

  • Rules-based feedback:定义规则 → 检查 → 报告失败原因(如 linting)
  • Visual feedback:截图 + 多模态审查(布局、样式、层级、响应式)
  • LLM-as-judge:另一个模型评估输出,适用于模糊标准场景(但不够健壮)

与其他概念的关联

References

  • sources/anthropic_official/building-agents-claude-agent-sdk.md