Single logo
  • Courses
  • Blog
  • About
Join free on SkoolJoin free on Skool

In this topic

Claude
  • CLAUDE.md, settings.json and Plugins: Which Claude Code File Advises, Which Enforces, Which Packages
  • Authoring a Claude Skill: SKILL.md, Frontmatter, Progressive Disclosure and the Description That Triggers It
  • One Change, Four Environments: Where a Claude Config Edit Lands in Dev, Staging, Prod and CI
  • Claude in the SDLC: Prompts in Git, a Change Gate by Path, a Claude Review That Advises and a Person Who Merges
  • Hooks That Block Destructive Actions: a PreToolUse Gate That Allows, Asks or Denies
  • Choosing a Claude Code Extension: Skill, Hook, Rules File, Subagent, Slash Command or Plugin
  • Rolling Out Claude Code to a Team: Settings Precedence, dontAsk in CI, a Hook for Every-Time Rules and a Plugin for Five Repos
  • A Claude Code Review Bot in CI: Headless -p, JSON Findings, Team Rules in Git and a Person on the Merge
  • Lab: Three Planted Bugs in a Claude Code CI Repo, a Permission Mode, a Plugin Path and an MCP Token Variable
  • Configuring MCP Servers in Claude Code: A Command or a URL, Three Scopes, and Three Moves When One Breaks
  • The Claude Messages API: Your First Call, Field by Field
  • Claude Tool Use: How tool_use and tool_result Work in the Messages API
  • Claude Client SDKs Wrap One REST API: Raw HTTP, Python, TypeScript and Async Calls Compared
  • Anthropic SDK Timeouts, Retries and Error Classes: Configure the Client Once, Then Give 429, 529, 400 and Timeouts Their Own Move
  • Claude Streaming Events: The Event Order, message_stop, Tool Arguments, Stop Reasons and a WebSocket Relay
  • Images, PDFs and Thinking Blocks in the Claude Messages API: Typed Blocks In, Typed Blocks Out
  • Getting Data Into Claude: PDF Documents, the Files API, Search Results and Citations
  • Opus, Sonnet or Haiku: Pick the Claude Model per Job, and Test the Request When a New Release Arrives
  • Adaptive Thinking and Effort in Claude: Two Dials, Set per Workload, and the Thinking Block You Must Pass Back
  • Claude Cost Tracking From usage: Count Before, Cap During, Read After, Then Find the Line That Drives the Bill
  • Claude Cache Breakpoints: Where to Put cache_control, How to Move It With the Chat, and Why the Reads Stay at Zero
  • Claude Message Batches or Real Time: Choose by Who Is Waiting, Match by custom_id, Resend Only the Failures
  • Calling Claude Through Amazon Bedrock, Google Cloud and Microsoft Foundry: Same Call, Different Door
  • The Life Cycle of a Claude App: Six Phases, a Model That Retires, and a Release Gate for Every Change
  • Pinning Claude Model IDs and Upgrading Safely: One Change at a Time, a Golden-Set Replay and a Staged Rollout
  • Content Boundaries and Schema Design for Claude: Fence the Input in a Tag, Let the Output Say I Don't Know
  • The Agentic Loop and stop_reason: Keep Turning on tool_use, Stop on end_turn, Cap the Turns
  • The Claude Agent SDK: query(), ClaudeAgentOptions and @tool, in Python and TypeScript
  • Fix the Agent: Four Broken Claude Agent SDK Configs, From the Symptom to the One Wrong Line
  • Claude Managed Agents: Cloud Sandbox, Self-Hosted Sandbox or Self-Hosted Service
  • Agent SDK Hooks for Deterministic Actions: PreToolUse, PostToolUse, and Four Hooks That Fail Silently
  • Memory and Context-Window Patterns for Claude Agents: Context Editing, Compaction and the Memory Tool
  • Reading an Agent Trace: Five Signatures, Five Missing Patterns, and How Long a Fact Must Live
  • Tool Descriptions for Claude: How Claude Picks a Tool, and How to Stop It Picking the Wrong One
  • Tool Input Schemas and Error Responses for Claude: Required Fields, Enums, is_error and a Retry Flag
  • Tool Response Shaping and a Lean Tool Set: Give Claude a Sticky Note, Not the Filing Cabinet
  • Fix the Tool Schema: Read the Trace, Fix the Card, Re-Run (Four Real Schema Bugs)
  • Client Tools, Server Tools and Approval Gates: Who Runs the Tool, and Who Says Yes First
  • Built-in Tool, Custom Tool, Skill or MCP Server? Pick the Lightest One That Fits
  • System Prompt or User Turn: Where Each Instruction Goes, and Output Limits Your Code Enforces
  • Refine the Prompt One Line at a Time, Then Clean and Fence the Customer's Text
  • Prompt Revision Driven by Evals: Name the Cause, Change One Thing, Rerun the Whole Suite
  • Long-Running Sessions: Compact, Prune, Isolate or Start Fresh, Decided by Naming the Failure
  • Context Isolation Through Subagents: Read the Logs Elsewhere, Keep One Line
  • Defensive Parsing of Claude Replies: Check the Stop Reason, Read the Block or the Text, Then Validate the Values
  • Full Context or Retrieval: Choose by Corpus Size, Cost and Freshness
  • Skepticism Toward Confident Output: Check the Quote, the Record and the Sum Before You Send
  • Debugging a Claude App: Three Error Types, the Recovery Each One Earns, and the First Failing Row
  • Six Ways a 200 Can Still Be Wrong: Hallucination, Refusal, Under-Acting, Context Loss, Format Drift and Inconsistency
  • Fix the Cause, Not the Symptom: Four Recovery Drills for an LLM App, Each Checked on a New Input
  • Integration Layer or Model Output? Three Taps and Three Questions to Find Where a Wrong Answer Lives
  • Which Test Layer Owns the Failure? Unit, Functional, Integration and End-to-End Tests for a Claude App
  • Designing an Overnight Document Pipeline on Claude: Batch Lane, Live Lane, a Cached Prefix and a custom_id Reconcile
  • Proving a Model Upgrade Is Ready: A Frozen Golden Set, a Calibrated Judge, the Right Layer and a Release Gate
  • From Requirement to Design for a Claude App: Eight Requirements, Five Elements and a Trace With No Gaps
  • Build a Claude Refund App: the Messages API, Two Tools, an MCP Server and a Hook in One Loop
  • Ship a Claude App: an Eval Gate, Two Guardrail Layers, a Cost Check From usage and a Pinned Model
  • Lab: a 30-Case Golden Set, a Calibrated Judge and a Per-Slice CI Gate on a Claude Refund App
  • Lab: Cut a Claude App's Bill by 62 Percent With Usage Data, Layered Cache Breakpoints and a Batch Job
  • Lab: Three Planted Bugs in a Claude App, a Vague Prompt, a Mistyped Tool Schema and a Broken Stream Handler
  • Lab: Three Planted Bugs in a Claude Code CI Repo, a Permission Mode, a Plugin Path and an MCP Token Variable
  • Lab: Harden a Claude App, an Uncalibrated Judge, a Retry Loop That Retries Everything and a Hook Matcher With a Gap
  • Lab: Turn a Claude App Into a Reusable Template, One Pinned Model Id, No Key in Code and Evals Built From Data
  • Building an MCP Server: Tools, Resources and Prompts in Python and TypeScript
  • MCP Transports: stdio or Streamable HTTP, and Who Starts the Server
  • Deploying and Authenticating an MCP Server: Environment Keys for stdio, Bearer Tokens and Scopes for HTTP
  1. Blog
  2. /
  3. Claude
  4. /
  5. Building with the Claude API

Claude Managed Agents: Cloud Sandbox, Self-Hosted Sandbox or Self-Hosted Service

One nightly triage agent, three homes. Claude Managed Agents splits an agent into a service and a sandbox; the cloud sandbox, a self-hosted sandbox and self-hosted Managed Agents differ only in which parts you host.

Chaand Sheikh

·27 November 2026Building with the Claude API

What you will learn

  • Split a Managed Agents deployment into the service (loop and storage) and the sandbox (where tools run)
  • Compare the cloud sandbox, a self-hosted sandbox and self-hosted Managed Agents by who hosts what
  • Create one agent and two environments, and start a session in each
  • Choose a hosting option from a stated requirement, not by default

Before you start

  • The Claude Agent SDK: query and ClaudeAgentOptions
  • Claude tool use: tool_use and tool_result

Our nightly triage agent runs commands on the support team's ticket files. Two questions come up before it ships: where do those commands run, and who runs the machine? Claude Managed Agents gives three answers, and the agent itself stays the same in all of them.

Managed Agents is in beta, so details can change. Check the Claude docs (Managed Agents overview, Self-hosted sandboxes) before you build on a specific option.

Two parts, and a choice for each

Think of two buildings. A head office plans the work: that's the service, with the agent loop and the storage for agents, sessions and history. A workshop does the work: that's the sandbox, where bash and the files live. The head office sends a tool call to the workshop, and the result comes back.

For each building you ask one question: do we host it, or does Anthropic? Each option's name says what you host.

Who hosts what in each Managed Agents option Model Service (loop, storage) Sandbox (tools) Cloud sandbox (default) Anthropic Anthropic Anthropic Self-hosted sandbox Anthropic Anthropic us (our worker) Self-hosted Managed Agents Claude API or a provider we pick us us
Read each row by who hosts what. The blue boxes are ours.

Option 1: the cloud sandbox

Anthropic runs everything. Each session gets its own fresh Linux container with common languages and tools already installed. You choose the network rules and any extra packages. What do you operate? Nothing. This is the default, so start here when you're not sure.

Option 2: a self-hosted sandbox

Claude and the agent loop still run on Anthropic's side, and Claude still picks the next tool call. But the call goes to a worker: a program you run on your own network. The worker runs it and sends the result back.

  • The files and processes stay on your worker.
  • The conversation history and the tool results still reach Anthropic, because the model needs to see them.
  • You operate the worker hosts: hardening, network limits and the environment key.
  • If no worker is connected, the session waits in the queue.

Option 3: self-hosted Managed Agents

Here you host the service as well. Inside your network you run the server, with the API, the agent loop and the storage. Your applications call it with the SDK or the ant CLI, and your workers poll the server for work. Each model call goes to an inference provider: the Claude API by default, or, per the lecture's source, Amazon Bedrock, Claude Models on Google Cloud, Microsoft Foundry or your own model gateway. You store agents, sessions and history yourself. Access goes through your Anthropic account team.

environments.py: one agent, two environments

The lecture project shows the difference in one small file. The agent is defined once; the environment says where its tools run.

"""One agent, two environments. The environment says where the tools run."""
from stand_in import MODEL


def setup(client):
    agent = client.beta.agents.create(
        name="SupportDesk triage", model=MODEL,
        tools=[{"type": "agent_toolset_20260401"}],
        system="Triage open tickets and write one report.")
    cloud = client.beta.environments.create(
        name="supportdesk-cloud",
        config={"type": "cloud"})
    own = client.beta.environments.create(
        name="supportdesk-own",
        config={"type": "self_hosted"})
    return agent, cloud, own

Then run_all.py starts one session in each environment, sends the same message, and reads the events:

"""Start one session in each environment and print what happens. Runs on the stand-in, no key."""
from environments import setup
from stand_in import make_client

WHERE = {"cloud": "Anthropic's sandbox", "self_hosted": "our own worker"}

client = make_client()
agent, cloud, own = setup(client)
print(f"agent {agent.id} version {agent.version}")

for env in (cloud, own):
    kind = env.config.type
    session = client.beta.sessions.create(
        agent={"type": "agent", "id": agent.id, "version": agent.version},
        environment_id=env.id)
    print(f"session in {kind}")
    print(f"  tools run in: {WHERE[kind]}")
    client.beta.sessions.events.send(session_id=session.id, events=[
        {"type": "user.message", "content": [{"type": "text", "text": "Triage tonight's open tickets"}]}])
    for e in client.beta.sessions.events.list(session_id=session.id).data:
        if e.type == "agent.tool_use":
            print(f"  tool call: {e.input['command']}")
        if e.type == "agent.message":
            print(f"  {e.content[0].text}")
        if e.type == "session.status_idle":
            print(f"  idle: {e.stop_reason.type}")
agent agent_test01 version 1
session in cloud
  tools run in: Anthropic's sandbox
  tool call: python triage.py --tickets open
  test model reply: the triage report is ready.
  idle: end_turn
session in self_hosted
  tools run in: our own worker
  tool call: python triage.py --tickets open
  test model reply: the triage report is ready.
  idle: end_turn

The stand-in answers with recorded-shape events, and the ids and the command are made up for the demo; no worker actually runs. What to notice: it's the same agent, version 1, in both sessions. Only the environment changed, and with it the place the tool call ran. In real code you create the agent once and keep its id, rather than creating it on every run.

Start from the need

RequirementOption
Tools don't need to run on your machinesCloud sandbox (default)
Tools must run on infrastructure you control, for example data that can't leave your networkSelf-hosted sandbox
You must store sessions yourself, or pick the inference providerSelf-hosted Managed Agents

Three cautions from the lecture:

  • Managed Agents is in beta.
  • With a self-hosted sandbox, the history and the tool results still reach Anthropic. It does not keep all data local.
  • Per the lecture, zero data retention doesn't apply to Managed Agents, except for self-hosted Managed Agents.

Common mistakes

  • "Self-hosting takes Anthropic out of the loop." With a self-hosted sandbox, Claude and the loop still run at Anthropic. Only the tools move.
  • Picking the most self-hosted option by reflex. Every step up adds things you operate. Move only when a requirement says so.
  • Confusing Managed Agents with the Agent SDK. The Agent SDK is a library you run in your own process. Managed Agents is a hosted service with stored, versioned agents and sessions.

Quick recap

OptionYou host
Cloud sandboxNothing
Self-hosted sandboxThe sandbox (your worker runs the tools)
Self-hosted Managed AgentsThe sandbox and the service; the model can come from a provider you choose

Same agent, three homes. Cloud first, then the sandbox, then the service.

Keep going in Claude · 30 of 66

Previous
Fix the Agent: Four Broken Claude Agent SDK Configs, From the Symptom to the One Wrong Line
Next post
Agent SDK Hooks for Deterministic Actions: PreToolUse, PostToolUse, and Four Hooks That Fail Silently
Community · Free to join
Single logo

StudyEasy AI Community

Hosted onSkool

Learn AI engineering, share what you build, and connect with other learners.

  • Free resources: lesson files, notebooks and code

  • Ask questions and join engineering discussions

  • Meet real people learning and building with AI

Join free on Skool

Related course on Udemy

Claude Certified Developer - Foundations (CCDV-F) Exam Prep

Build and ship Claude apps: the API, agents, tools and MCP, prompts, evals, security and model choice.View on Udemy ↗: Claude Certified Developer - Foundations (CCDV-F) Exam Prep (paid course, opens in a new tab)

Related posts

The Claude Messages API: Your First Call, Field by Field

One request in, one Message out. The four fields of a Messages API call (model, max_tokens, system, messages), how to read content blocks, stop_reason and usage, and why every turn resends the history.

Claude Tool Use: How tool_use and tool_result Work in the Messages API

Follow one order question through Claude's tool round trip: define a tool, read the tool_use block, run your own function and send a matching tool_result back, including parallel calls and is_error.

Claude Client SDKs Wrap One REST API: Raw HTTP, Python, TypeScript and Async Calls Compared

Every Claude client SDK wraps the same REST request: a POST to /v1/messages with a JSON body. See it built by hand, through the Python and TypeScript SDKs, as typed errors, and as async calls that wait together.

Anthropic SDK Timeouts, Retries and Error Classes: Configure the Client Once, Then Give 429, 529, 400 and Timeouts Their Own Move

Configure the Anthropic SDK client (timeout, max_retries, with_options, async, pagination), see which errors it retries by itself, then repair a retry wrapper so a 429, a 529, a 400 and a timeout each get the move the docs support.

On this page

  • Two parts, and a choice for each
  • Option 1: the cloud sandbox
  • Option 2: a self-hosted sandbox
  • Option 3: self-hosted Managed Agents
  • environments.py: one agent, two environments
  • Start from the need
  • Common mistakes
  • Quick recap
Community · Free to join
Single logo

StudyEasy AI Community

Hosted onSkool

Learn AI engineering, share what you build, and connect with other learners.

  • Free resources: lesson files, notebooks and code

  • Ask questions and join engineering discussions

  • Meet real people learning and building with AI

Join free on Skool

Related course on Udemy

Claude Certified Developer - Foundations (CCDV-F) Exam Prep

Build and ship Claude apps: the API, agents, tools and MCP, prompts, evals, security and model choice.View on Udemy ↗: Claude Certified Developer - Foundations (CCDV-F) Exam Prep (paid course, opens in a new tab)

Single logo

Empowering Education, One Course at a Time

About
About usContact usFAQs
Legal
Terms of ServicePrivacy Policy

© 2026 StudyEasy Organization. All rights reserved.