Advanced Tool Use & Agent Engineering

Agent SDK vs. Managed Agents: Same Loop, Different Hosting

Anthropic ships two ways to run Claude as an autonomous agent. The capability is similar; the operational model — and the platform availability — could hardly be more different.

Claude 3P 101 · Updated July 2026 · Unofficial guide

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 SDKManaged Agents
RunsIn your process, your infrastructureAnthropic's orchestration layer + hosted container
InterfaceLibrary (query() in Python/TypeScript)REST API (agents, environments, sessions, events)
Session stateJSONL on your filesystemServer-side sessions, event history persisted
3P availabilityDocumented on all four surfaces via env varsBeta on 1P and Claude Platform on AWS only
Ops burdenYou run and scale the workersAnthropic 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.

Anthropic's own suggested path: prototype with the Agent SDK locally, then move to Managed Agents for production — if your platform allows it. Also note Managed Agents' stateful design makes it ineligible for Zero Data Retention and HIPAA BAA coverage today, though sessions and files can be deleted via the API at any time.

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.

Sources