Understanding Computer Use

The Claude Agent SDK

4 min read

Anthropic released the Claude Agent SDK - the same infrastructure powering Claude Code - to help developers build sophisticated agents without reinventing the wheel.

What is the Agent SDK?

The Agent SDK provides:

  • Pre-built agentic loops for Computer Use and tool calling
  • State management for long-running sessions
  • Error recovery patterns
  • Observability hooks for debugging

Core Components

from anthropic import Anthropic
from anthropic.tools import ComputerTool, BashTool, TextEditorTool

# Initialize with Computer Use tools
client = Anthropic()

tools = [
    ComputerTool(),      # Screen control
    BashTool(),          # Terminal commands
    TextEditorTool(),    # File editing
]

The Agent Loop Pattern

The SDK simplifies the agentic loop:

async def run_agent(task: str):
    messages = [{"role": "user", "content": task}]

    while True:
        response = await client.messages.create(
            model="claude-sonnet-4-5-20250514",
            max_tokens=4096,
            tools=tools,
            messages=messages,
            betas=["computer-use-2025-01-24"]
        )

        # Check if agent is done
        if response.stop_reason == "end_turn":
            return extract_result(response)

        # Execute tool calls
        tool_results = await execute_tools(response.content)

        # Add to conversation
        messages.append({"role": "assistant", "content": response.content})
        messages.append({"role": "user", "content": tool_results})

Agent Skills

Agent Skills extend Claude's capabilities with specialized knowledge:

# Skills are loaded dynamically
skills = [
    "anthropic/excel",      # Work with Excel files
    "anthropic/powerpoint", # Create presentations
    "anthropic/pdf",        # Process PDF documents
]

Skills are versioned (e.g., skills-2025-10-02) and can include:

  • Instructions and prompts
  • Scripts and code
  • Resource files

Why Use the SDK?

Without SDK With SDK
Build loop from scratch Pre-built agent loop
Handle all edge cases Built-in error recovery
Manual state tracking Automatic state management
Custom debugging Observability hooks

Note: The Agent SDK uses the same patterns that power Claude Code, Anthropic's AI coding assistant.

In the next module, we'll set up your development environment to start building. :::

Quiz

Module 1: Understanding Computer Use

Take Quiz