Managed Agents and Platform Tooling
In Claude Managed Agents (beta) Anthropic both runs the agent loop and provides a sandbox container for every session. You do not need to write the loop, state files or a scheduler.
20.1 Core objects
| Object | What it is | How often to create |
|---|---|---|
| Environment | Container config: networking (limited/unrestricted), packages, MCP access | Once, reuse |
| Agent | Stored, versioned config: model, system prompt, tools, skills, MCP servers | Once, store the ID |
| Session | One run; its own workspace container; events stream | New for each task |
| Vault | Credentials (API keys, MCP OAuth) — substituted at egress, never visible in the sandbox | Once |
| Deployment | Run an agent on a cron schedule ("report every night") | As needed |
| Memory store | Memory that persists across sessions | As needed |
- 1.Environment: environments.create
- 2.Agent: agents.create (once)
- 3.Session: sessions.create (every run)
- 4.Events: send user.message, read the SSE stream
- 5.Result: files, messages, outcome
Create the agent once; never run agents.create in the request path
env = client.beta.environments.create(name="dev-env", config={
"type": "cloud",
"networking": {"type": "limited", "allow_package_managers": True, "allow_mcp_servers": True},
})
agent = client.beta.agents.create( # create once, save the ID
name="Code Reviewer", model="claude-opus-5-5",
system="You are a strict code reviewer.",
tools=[{"type": "agent_toolset_20260401",
"default_config": {"enabled": True, "permission_policy": {"type": "auto"}},
"configs": [{"name": "web_search", "enabled": False},
{"name": "web_fetch", "enabled": False}]}],
)
session = client.beta.sessions.create(
agent={"type": "agent", "id": agent.id, "version": agent.version},
environment_id=env.id,
)
with client.beta.sessions.events.stream(session_id=session.id) as stream: # open the stream first
client.beta.sessions.events.send(session_id=session.id, events=[
{"type": "user.message", "content": [{"type": "text", "text": "review the auth module"}]}])
for event in stream:
if event.type == "agent.message":
for b in event.content:
if b.type == "text": print(b.text, end="")20.2 Advanced Managed Agents features
| Feature | What it does |
|---|---|
| Permission policies | always_allow, always_ask, auto (the server stops risky calls / asks for approval) |
| Outcomes | user.define_outcome + rubric — a separate grader agent keeps it iterating until the rubric passes |
| Multi-agent / workflows | A lead agent splits the work into phases across several agents (cheaper worker model) |
| Scheduled deployments | Autonomous sessions on cron; pause/unpause/archive |
| Webhooks | Notify your server on session events |
| Session budgets | A hard dollar cap for one session |
| File mounts / GitHub | Work by uploading files or mounting a repo |
| Self-hosted sandboxes | Tool execution on your own infra |
| Console session viewer | See each session's trace with no setup |
20.3 ant CLI
Anthropic's command-line tool. Rule: the CLI is for the control plane (defining agents, environments), the SDK is for the data plane (running sessions).
ant auth login # browser OAuth; profile ~/.config/anthropic/ (Windows: %APPDATA%\Anthropic)
ant auth status # which credential is active
ant auth login --profile admin --scope "... org:admin" # privileged work on a separate profile
ant beta:agents list --transform '{id,name,model}' --format jsonl
ant beta:sessions:events list --session-id session_01...
ant apply # sync agents/*.md, environment.yaml... in the repo; IDs go in claude-lock.json20.4 Admin, monitoring and auth
| Feature | Detail |
|---|---|
| Admin API (beta) | Members, invites, workspaces, API keys, rate limit reports, service accounts — with an Admin key (sk-ant-admin...) |
| Usage & Cost reports | usage_report/messages, cost_report — raw HTTP; spend tracking |
| OpenTelemetry | The SDK emits a span for every request (C#: AddSource("com.anthropic.sdk.csharp*")); traces in Datadog/Grafana |
| Workload Identity Federation | CI/cloud workloads authenticate with their own identity token (JWT), without a static API key |
| Workspaces | Separate keys, limits, spend for teams/projects |
| Credential order | ANTHROPIC_API_KEY → ANTHROPIC_AUTH_TOKEN → ant profile → WIF |