TOOL WIKI · AGENT SDKS

Claude Agent SDK

Exposes Claude’s agent loop and built-in tools for working in an application environment.

Download example files Code + setup + checks in a ZIP
Jump to a section 10 sections

EXAMPLE USE CASE

Summarize a project using file evidence

A developer needs a small, observable agent or retrieval step before connecting real business services.

Input
A sample-project directory with README.txt and read/search tools.
Expected output
A purpose summary naming the files used and the terminal outcome.
  • Success check: The result names README.txt and describes the fixture.
  • Try a failure: Remove README.txt and check that the agent reports missing evidence.

Example scope: Actual file-reading agent; the example exposes no write or shell tool.

Official reference · Claude Agent SDK

WHAT IT ISAgent SDK
WHERE IT FITSAgent SDKs
SEE HOW THE SYSTEM FITS TOGETHERSELECT A COMPONENT
taskinvokedecisiontool callresultstatemeasureApplicationTask + identityClaude Agent SDKAgent SDKModel providerConfigured API modelTool serviceAuthorization + executionState storageRun and thread progressEvaluationOutcome + evidence
  1. Authenticate the request and define the goal before calling the framework.

  2. Tasks that benefit from a working directory and file or code tools. Configure the available tool inventory separately from tool approval.

  3. The application supplies provider credentials, model selection, and budgets.

  4. Validate each operation and return authoritative observations.

  5. Choose the checkpoint or session store and its retention policy deliberately.

    Result or stopping point
  6. Check completion, cost, latency, and tool behavior against fixtures.

    Result or stopping point
Claude Agent SDK

Tasks that benefit from a working directory and file or code tools. Configure the available tool inventory separately from tool approval.

Follow the arrows, then select a component to inspect its responsibility. On mobile, downward arrows connect the next step; bent arrows identify branches and return paths. Select a destination to jump to that component.

When to consider it

  • Tasks that benefit from a working directory and file or code tools.

A design decision to make

  • Configure the available tool inventory separately from tool approval.

Prerequisites and setup

  • Python 3.11+ in an empty directory. A compatible model and provider credentials are required.
  • Running the model-backed example can incur API charges; this website displays it without calling a provider.
  • Save the code at the displayed path, then use the corresponding run command.
Shell
python3 -m venv .venv
source .venv/bin/activate
python -m pip install claude-agent-sdk
export ANTHROPIC_API_KEY="your-api-key"
mkdir -p sample-project
printf "A tiny order-status service.\n" > sample-project/README.txt

Try a small integration

review.py

Python · review.py
import asyncio
from claude_agent_sdk import (
    query, ClaudeAgentOptions, ResultMessage
)

async def main():
    options = ClaudeAgentOptions(
        cwd="./sample-project",
        tools=["Read", "Glob", "Grep"],
        allowed_tools=["Read", "Glob", "Grep"],
        max_turns=5,
    )
    async for message in query(
        prompt=(
            "Read the text files in this project. "
            "Summarize its purpose and name the files you used."
        ),
        options=options,
    ):
        if isinstance(message, ResultMessage):
            print("Outcome:", message.subtype)
            print(message.result or "No final text returned.")

if __name__ == "__main__":
    asyncio.run(main())

Run and check the result

Shell
python review.py
  • The result names README.txt and describes the fixture.
  • The available tools are Read, Glob, and Grep; the sample supplies no write or shell tool.

Common failures

  • A missing working directory fails before useful file analysis; create sample-project first.
  • Inspect ResultMessage.subtype as well as result text. A turn limit or tool failure is not a successful review.

Production decisions

  • Replace the local fixture with a service that enforces authenticated tenant and resource permissions.
  • Add timeouts, bounded retries, tracing redaction, and a regression case for each observed failure.
  • Model calls consume provider API usage when you run this example; this website only displays the code.
Read the Claude Agent SDK walkthrough

Keep exploring

Workflow, single agent, or multiple agents?Build an explicit agent loop with LangGraph

Explore the same layer

OpenAI Agents SDKGoogle ADKLangGraphLangChain

Compare candidates on your own workload. This entry describes a product’s role; it is not a claim that products in the category are interchangeable.