An "agent" here means Claude running a loop: read the task, call tools, examine results, call more tools, finish. With the plain client SDK you build that loop yourself — checking for stop_reason: "tool_use", executing the tool, sending back results. Anthropic offers two products that run the loop for you, and choosing between them is mostly a question of where you want the loop to live.
The Agent SDK: the loop in your process
The Claude Agent SDK packages the same tools, agent loop, and context management that power Claude Code as a library — claude-agent-sdk on pip (Python 3.10+) and @anthropic-ai/claude-agent-sdk on npm, with the TypeScript package bundling a native Claude Code binary so nothing needs separate installation. You call query(), and Claude autonomously runs tools — built-ins include Read, Write, Edit, Bash, Glob, Grep, WebSearch, WebFetch, and AskUserQuestion — inside your process, on your infrastructure.
Because it runs where your code runs, everything is local: session state is stored as JSONL files on your filesystem, and the first query's init message carries a session_id you can pass back as resume to continue with full context (sessions can also be forked to explore alternatives). Control comes from allowed_tools pre-approval, permission_mode settings such as "acceptEdits", lifecycle hooks (PreToolUse, PostToolUse, Stop, and more), and subagent definitions. It also loads Claude Code's filesystem configuration by default — Skills, commands, CLAUDE.md memory — from .claude/ directories, restrictable via setting_sources. MCP support includes local command-based servers, which the Messages-API connector cannot reach.
Managed Agents: the loop on Anthropic's infrastructure
Claude Managed Agents (beta; all endpoints require the managed-agents-2026-04-01 header, which the SDK sets automatically) is a hosted REST API. You create a persistent, versioned agent object, an environment template, then start sessions; Anthropic provisions a container per session as the agent's workspace, runs the loop on its orchestration layer, and streams events back over Server-Sent Events. Sessions are stateful server-side — filesystem, conversation history, outputs — and the platform adds conveniences you would otherwise build: automatic context compaction near the context limit, prompt caching of repeated history, scheduled deployments, credential vaults, and memory stores.
Side by side
| Agent SDK | Managed Agents | |
|---|---|---|
| Runs | In your process, your infrastructure | Anthropic's orchestration layer + hosted container |
| Interface | Library (query() in Python/TypeScript) | REST API (agents, environments, sessions, events) |
| Session state | JSONL on your filesystem | Server-side sessions, event history persisted |
| 3P availability | Documented on all four surfaces via env vars | Beta on 1P and Claude Platform on AWS only |
| Ops burden | You run and scale the workers | Anthropic runs the containers |
The availability row is often the deciding one. Managed Agents is beta on the first-party API and Claude Platform on AWS, and not supported on Bedrock, Vertex AI, or Foundry. The Agent SDK, by contrast, is the documented agent path on all four third-party surfaces: CLAUDE_CODE_USE_BEDROCK=1, CLAUDE_CODE_USE_ANTHROPIC_AWS=1 (plus ANTHROPIC_AWS_WORKSPACE_ID), CLAUDE_CODE_USE_VERTEX=1, and CLAUDE_CODE_USE_FOUNDRY=1. If your model traffic must stay on Bedrock, Vertex, or Foundry Hosted-on-Azure, the SDK is your only Anthropic-documented option.
How to pick
Choose the Agent SDK when you need Bedrock, Vertex, or Foundry; when data or tool execution must stay inside your network; when you want deep customization via hooks and local MCP servers; or when you already operate the compute anyway. Two commercial notes: API-key auth is required (offering claude.ai login in your product is not allowed without prior approval), and partner products may say "Powered by Claude" but not "Claude Code."
Choose Managed Agents when you are on the first-party API or Claude Platform on AWS and want long-running, stateful, scheduled agent sessions without building worker infrastructure — the minutes-to-hours, many-tool-call workloads it is explicitly designed for. (A middle path exists: Managed Agents' self-hosted sandboxes keep Anthropic's orchestration but move tool execution into a container you control.)
Where to go next
For the SDK route, see Bedrock, Google Cloud, and Foundry setup. For the hosted route, start with Managed Agents sessions and Managed Agents on Claude Platform on AWS.