DEV Community

DanXiao
DanXiao

Posted on

Understanding Intelligent Agents Starting with Claude Agent SDK

What is the Claude Agent SDK?

In simple terms, it is a development framework/library that allows developers to use Claude as an "intelligent brain" to build automated agents, which have the ability to:

  • Read files, execute commands, search the web, and more
  • Automatically manage conversation context, avoiding context misalignment
  • Run complex workflows rather than single Q&A
  • Support Python and TypeScript/Node.js development environments

Agent Runtime (Agent Loop)

The SDK includes a complete agent loop, which consists of:

  • Decision: Understand the task
  • Planning: Choose the right tools and steps
  • Execution: Invoke tools (such as files, commands, web, etc.)
  • Verification: Check execution results and proceed to the next step

This means you don't have to write coordination logic yourself; just use query() to let the SDK decompose, execute, and provide feedback on the task.

πŸ“Œ Compared to traditional LLM APIs, the Agent SDK is not just a single prompt β†’ response; it is a system that runs continuously, maintains state, and can perform actions.

What functions and tools are supported?

The SDK provides a lot of built-in functions, including but not limited to:

  • File operations (reading, editing, creating files)
  • Command execution (running shell or scripts)
  • Code editing and generation
  • Web search, API calls, etc. (integrated via MCP standards)
  • Managing permissions and tool access control mechanisms (to prevent dangerous operations)

What underlying models are supported?

  • The SDK internally drives agent logic and tool execution through the Claude Code runtime.
  • You need to set the ANTHROPIC_API_KEY and connect to Anthropic's API for authentication.

So based on the official design, it essentially supports the Claude series of models (like Claude Agent / Claude Code) and is built around this ecosystem.

But can access other platforms via third-party API providers

The documentation clearly states that you can configure some environment variables to let the SDK use:

  • Amazon Bedrock
  • Google Vertex AI
  • Microsoft Foundry

As underlying model providers (though you still need credentials and settings for these platforms).

Comparison with Codex CLI

Comparison Point Claude Agent SDK codex-cli
Nature Development framework (SDK) Command-line tool (CLI)
Target Users People building systems/products/agent platforms Developers for daily coding tasks
Usage Integrated into your project via code Used directly in the terminal
Can it run long-term? βœ… Yes (persistent agent) ❌ No (one command, one result)
Automatic multi-step execution βœ… Can split tasks and execute steps automatically ❌ You have to issue each step manually
β€œThink-Execute Loop” βœ… Built-in Agent Loop ❌ Not available
Can run as a background service βœ… Yes ❌ Not suitable
File / Code manipulation βœ… Yes (controllable and programmable) βœ… Yes (mostly local development)
Execute shell commands βœ… Yes βœ… Yes
Extensible tools βœ… Very strong (MCP / custom tools) ⚠️ Limited
Multi-agent collaboration βœ… Supported ❌ Not supported
Production-ready βœ… Designed for product use ❌ Not designed for production
Learning curve Medium Low
Abstraction level High (like building a robot) Low (like using a tool)

My own understanding:

  • codex-cli is "an AI tool"
  • Claude Agent SDK is "a tool for developers to create AI agents"

Process of developing an agent with Claude agent

1️⃣ Clarify requirements

Determine what kind of agent you want to develop, what its role is, what tasks it will be responsible for, and what outputs count as success, avoiding vague goals from the start.

2️⃣ Define roles

Write a long-term effective system prompt for the agent, clarifying its identity, responsibilities, working style, and basic rules, rather than a one-time Q&A prompt.

3️⃣ Configure tools

Decide which tools the agent can use, such as reading and writing files, executing commands, or accessing APIs, only granting necessary permissions to avoid uncontrolled behavior.

4️⃣ Launch the agent

Pass the goals and configurations through the Claude Agent SDK, start the agent loop, allowing the agent to decompose tasks and execute them step by step.

5️⃣ Observe behavior

Check the agent's execution process and the sequence of tool calls to determine whether it is working as expected and if there are any repetitions, deviations from goals, or failures.

6️⃣ Iterate and optimize

Continuously adjust the role descriptions, tool permissions, and output formats based on the running results to make the agent more stable and efficient.

7️⃣ System integration

Integrate the mature agent into scheduled tasks, APIs, or multi-agent processes, making it part of the system rather than a one-off script.

Comparison with Langchain

Comparison Point Claude Agent SDK LangChain
Core Positioning Executable agent, automatically splits tasks and calls tools Agent framework, combines LLM + tools + workflow
Model Binding Deeply integrated with Claude Model-agnostic, can use OpenAI / Anthropic / others
Execution Method Built-in Agent Loop, long-running with persistent state Requires manual composition of logic, on-demand execution
Complex Workflow Support Primarily single-agent execution; complex workflows need external orchestrator Built-in chains, vector DBs, supports complex workflows
Target Users Quickly build production-grade agents, focus on task execution Developers who want flexible combination of models, tools, and workflows

Claude Agent SDK provides a ready-made agent execution engine, enabling you to quickly create runnable agents; LangChain offers a framework and tools for you to build the structure and processes of your agent.

Reference Documentation

Top comments (0)