Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 6 additions & 1 deletion docs.json
Original file line number Diff line number Diff line change
Expand Up @@ -54,9 +54,9 @@
{
"group": "Agents in sandbox",
"pages": [
"docs/agents/anthropic-managed-agents",
"docs/agents/amp",
"docs/agents/claude-code",
"docs/agents/claude-managed-agents",
"docs/agents/codex",
"docs/agents/devin",
"docs/agents/openai-agents-sdk",
Expand Down Expand Up @@ -3727,6 +3727,11 @@
}
},
"redirects": [
{
"source": "/docs/agents/anthropic-managed-agents",
"destination": "/docs/agents/claude-managed-agents",
"permanent": true
},
{
"source": "/docs/troubleshooting/pip-install-error",
"destination": "/docs/faq/pip-install-error",
Expand Down
Original file line number Diff line number Diff line change
@@ -1,13 +1,17 @@
---
title: "Anthropic Managed Agents"
description: "Use E2B as the sandbox runtime for Anthropic Managed Agents self-hosted environments."
title: "Claude Managed Agents"
description: "Use E2B as the sandbox runtime for Claude Managed Agents self-hosted environments."
icon: "/images/icons/claude-code.svg"
---

[Anthropic Managed Agents](https://platform.claude.com/docs/en/managed-agents/overview) can use a self-hosted environment when you want to run tool calls in your own infrastructure. E2B provides a reusable `E2B/claude-managed-agents-webhooks` template that receives Anthropic webhooks and routes each Managed Agents session to a persistent E2B worker sandbox.
[Claude Managed Agents](https://platform.claude.com/docs/en/managed-agents/overview) can use a self-hosted environment when you want tool calls to run in your own infrastructure. Claude runs the agentic loop and reasoning process; E2B provides isolated sandbox infrastructure for the environment where tool calls execute. The reusable `E2B/claude-managed-agents-webhooks` template receives webhooks and routes each Claude Managed Agents session to a persistent E2B worker sandbox.

Check warning on line 7 in docs/agents/claude-managed-agents.mdx

View check run for this annotation

Mintlify / Mintlify Validation (e2b) - vale-spellcheck

docs/agents/claude-managed-agents.mdx#L7

Did you really mean 'agentic'?

<Info>
For the full source, local setup scripts, and app-owned routing examples, see the [Anthropic Managed Agents cookbook](https://github.com/e2b-dev/e2b-cookbook/tree/main/examples/anthropic-managed-agents).
This separation is intentional for security: Claude decides what work to do, while the sandbox contains the execution environment, filesystem, tools, network access, and runtime logs.
</Info>

<Info>
For the full source, local setup scripts, and app-owned routing examples, see the [Claude Managed Agents cookbook](https://github.com/e2b-dev/e2b-cookbook/tree/main/examples/anthropic-managed-agents).
</Info>

## Install dependencies
Expand All @@ -28,20 +32,20 @@
# E2B dashboard API keys: https://e2b.dev/dashboard?tab=keys
export E2B_API_KEY="..."

# Anthropic Console API keys: https://console.anthropic.com/settings/keys
# Claude Console API keys: https://console.anthropic.com/settings/keys
export ANTHROPIC_API_KEY="..."

# Anthropic Console environments: https://platform.claude.com/workspaces/default/environments
# Claude Console environments: https://platform.claude.com/workspaces/default/environments
export ANTHROPIC_ENVIRONMENT_ID="..."

# Open the self-hosted environment in the Anthropic Console and click Generate environment key.
# Open the self-hosted environment in the Claude Console and click Generate environment key.
export ANTHROPIC_ENVIRONMENT_KEY="..."
```

## Start the webhook sandbox

Start the public template with auto-resume enabled. The template starts a webhook server on port `8000`.
Because Anthropic only shows the webhook signing key after you register an endpoint, write the router config now and add the signing key to the same sandbox after registration.
Because the signing key only appears after you register a webhook endpoint, write the router config now and add the signing key to the same sandbox after registration.

<CodeGroup>
```typescript JavaScript & TypeScript
Expand Down Expand Up @@ -109,7 +113,7 @@

## Register the webhook

In the [Anthropic Console webhooks settings](https://platform.claude.com/settings/workspaces/default/webhooks), create a webhook endpoint using the printed URL:
In the [Claude Console webhooks settings](https://platform.claude.com/settings/workspaces/default/webhooks), create a webhook endpoint using the printed URL:

```text
https://<sandbox-host>/webhook
Expand Down Expand Up @@ -143,25 +147,25 @@
```
</CodeGroup>

## Send work to the agent
## Run an end-to-end smoke test

Create or select a Managed Agents agent in the [Anthropic Console](https://platform.claude.com/workspaces/default/agents), then create a session with that agent and the same `ANTHROPIC_ENVIRONMENT_ID` you wrote into the webhook sandbox. Creating the session does not start work; the `user.message` event does.
Create or select a Claude Managed Agents agent in the [Claude Console](https://platform.claude.com/workspaces/default/agents), then create a session with that agent and the same `ANTHROPIC_ENVIRONMENT_ID` you wrote into the webhook sandbox. Creating the session does not start work; the `user.message` event does.

```bash
export ANTHROPIC_AGENT_ID="agent_..."
```

Use a small sandbox task for the first smoke test:
Use a small shell task for the first smoke test:

```text
Use bash to echo webhook-smoke-ok. Answer only with that text.
```

<CodeGroup>
```typescript JavaScript & TypeScript
import Anthropic from '@anthropic-ai/sdk'
import Claude from '@anthropic-ai/sdk'

const client = new Anthropic({
const client = new Claude({
apiKey: process.env.ANTHROPIC_API_KEY,
})

Expand Down Expand Up @@ -190,9 +194,9 @@

```python Python
import os
import anthropic
from anthropic import Anthropic as Claude

client = anthropic.Anthropic(api_key=os.environ["ANTHROPIC_API_KEY"])
client = Claude(api_key=os.environ["ANTHROPIC_API_KEY"])

session = client.beta.sessions.create(
agent=os.environ["ANTHROPIC_AGENT_ID"],
Expand All @@ -219,6 +223,12 @@
```
</CodeGroup>

Claude should answer:

```text
webhook-smoke-ok
```

Then check the webhook sandbox:

<CodeGroup>
Expand Down Expand Up @@ -261,30 +271,30 @@
- `/health` returning `ok: true`.
- Router logs showing `routing work` and `assigned session`.
- A session-to-sandbox assignment in the router's assignment store.
- The assigned worker sandbox's `worker.log` showing claimed work, tool execution, and successful results posted back to Anthropic.
- The Anthropic session returning to `session.status_idle`.
- The assigned worker sandbox's `worker.log` showing the shell tool execution and successful results posted back to Claude.
- The Claude Managed Agents session returning to `session.status_idle`.

The assignment store records the worker sandbox ID for each routed session. Connect to that sandbox and check `/opt/anthropic-managed-agents-js/worker.log` when you need the tool execution logs.

If the session stays at `requires_action`, check `/opt/anthropic-managed-agents-js/webhook.log` in the router sandbox first, then check `/opt/anthropic-managed-agents-js/worker.log` in the assigned worker sandbox. Stale environment keys, missing signing keys, archived sessions, and failed tool-result posts show up there.

## Runtime behavior

The worker runs with `/mnt/session` as its workdir. File tools are constrained to that workdir, skills are downloaded under `/mnt/session/skills/<name>/`, and generated artifacts should be written under `/mnt/session/outputs`.
The worker sandbox runs tool calls with `/mnt/session` as its workdir. File tools are constrained to that workdir, skills are downloaded under `/mnt/session/skills/<name>/`, and generated artifacts should be written under `/mnt/session/outputs`.

Check warning on line 283 in docs/agents/claude-managed-agents.mdx

View check run for this annotation

Mintlify / Mintlify Validation (e2b) - vale-spellcheck

docs/agents/claude-managed-agents.mdx#L283

Did you really mean 'workdir'?

Check warning on line 283 in docs/agents/claude-managed-agents.mdx

View check run for this annotation

Mintlify / Mintlify Validation (e2b) - vale-spellcheck

docs/agents/claude-managed-agents.mdx#L283

Did you really mean 'workdir'?

The webhook sandbox is the router. It keeps a session-to-sandbox assignment store and starts worker sandboxes with E2B auto-resume and pause-on-timeout settings.

## Session-scoped sandboxes

By default, the public webhook template gives each Managed Agents session its own E2B worker sandbox. Follow-up turns for the same session reconnect to the same worker and reuse its `/mnt/session` filesystem.
By default, the public webhook template gives each Claude Managed Agents session its own E2B worker sandbox. Follow-up turns for the same session reconnect to the same worker and reuse its `/mnt/session` filesystem. The sandbox is the isolated execution environment, not the place where Claude's reasoning loop runs.

Use [cloud buckets](/docs/storage/cloud-buckets), [Archil](/docs/storage/archil), or [volumes](/docs/volumes) when files need to outlive a sandbox or be shared across many sandboxes.

If you want to run that router in your own service instead of in E2B, use the cookbook's [`app-webhooks/` example](https://github.com/e2b-dev/e2b-cookbook/tree/main/examples/anthropic-managed-agents/javascript/app-webhooks). It receives Anthropic webhooks in your app, claims work there, and routes each session to its own E2B sandbox by default.
If you want to run that router in your own service instead of in E2B, use the cookbook's [`app-webhooks/` example](https://github.com/e2b-dev/e2b-cookbook/tree/main/examples/anthropic-managed-agents/javascript/app-webhooks). It receives webhooks in your app, claims work there, and routes each session to its own E2B sandbox by default.

## Clean up

Remove the webhook endpoint in the Anthropic Console before deleting the router sandbox. Then kill the router sandbox and any assigned worker sandboxes you no longer need.
Remove the webhook endpoint in the Claude Console before deleting the router sandbox. Then kill the router sandbox and any assigned worker sandboxes you no longer need.

## Related guides

Expand Down
Loading