Claude on WholeTech network
home/products/agent-sdk
Build agents

Agent SDK shipping

Anthropic's higher-level harness for building agents — programs that loop, use tools, and pursue a goal until done.

01 — In one sentence

The harness Claude Code is built on.

If you've used Claude Code and wondered "how is it doing all this looping," the answer is: the Agent SDK. You can build your own version on the same infrastructure — a goal, some tools, a budget, and Claude runs until done.

What you get

02 — When to use the SDK vs plain API

Different jobs.

Reach for the plain API

Single-shot calls. Structured I/O. Classification. Extraction. You control the prompt; you parse the answer.

Reach for the Agent SDK

Multi-step work where Claude needs to read files, run code, make decisions, iterate. You hand it a goal; it figures out the steps.

03 — First agent

From zero to a running loop.

  1. Install: pip install claude-agent-sdk or npm install @anthropic-ai/claude-agent-sdk.
  2. Write a goal as a plain-English instruction: "Read every .md file in ./docs, find broken links, write a report to ./report.md."
  3. Pick the tools the agent is allowed to use (file tools yes, bash maybe, web fetch maybe).
  4. Run it. The SDK loops, calls tools, reports back when done.
from claude_agent_sdk import Agent
agent = Agent(
    model="claude-sonnet-4-6",
    tools=["read_file","write_file","glob","grep"],
    goal="Find broken links in ./docs and write a report to ./report.md",
    max_steps=40,
)
agent.run()
04 — Patterns that work

Three shapes you'll reuse.

Loop-until-done

Single agent, file + bash tools, plain goal. Walk away. Most Claude Code uses live here.

Planner + workers

One agent breaks the job into chunks, spawns sub-agents, collects results. Use sub-agents when chunks are independent.

Tool-only orchestrator

The agent never reads or writes files; it only orchestrates calls to your in-house APIs. Useful when data must stay in your systems.

05 — Operational habits

Don't ship without these.

Treat agents like junior employees with admin rights. Sandbox first, narrow scope, watch the first few runs.