skills/claude-agent-sdk/managed-agents-api/SKILL.md
Use Anthropic's Managed Agents API (/v1/agents, /v1/sessions) — server-side agent runtime that handles the tool loop, compaction, memory, and scaling for you. Covers when to pick Managed over SDK, request shape, and cost model. Use this skill when building production agents at scale, deciding between SDK vs Managed, or migrating from self-hosted agent loops. Activate when: Managed Agents API, /v1/agents, /v1/sessions, server-side agent, Anthropic agent runtime.
npx skillsauth add latestaiagents/agent-skills managed-agents-apiInstall this skill globally with one command. Works with Claude Code, Cursor, and Windsurf.
3 of 9 scanners reported clean
Some scanners were skipped, did not run, or reported a non-clean status. Review each row below.
The Managed Agents API lets Anthropic run the agent loop server-side. You POST a user message; they run the tool loop, manage context, and stream results. You lose control but gain simplicity and durability.
/v1/agents) — a template: name, system prompt, tools, model/v1/sessions) — a live conversation bound to an agentconst agent = await client.beta.agents.create({
name: "support-bot",
description: "Customer support for ACME",
model: "claude-sonnet-4-6",
system_prompt: "You are ACME's support agent. Be concise and accurate.",
tools: [
{ type: "search_tickets", name: "search_tickets", /* schema */ },
{ type: "create_escalation", name: "create_escalation" },
],
mcp_servers: [
{ type: "url", url: "https://mcp.acme.com/sse", name: "acme" },
],
});
// Returns: { id: "agt_...", name: "support-bot", ... }
Agents are versionable — update without breaking live sessions.
const session = await client.beta.sessions.create({
agent_id: agent.id,
metadata: { user_id: "u-42", ticket_id: "T-1001" },
});
// Returns: { id: "ses_...", agent_id: "agt_...", status: "idle", ... }
Metadata is yours to use for filtering, auditing, linking to your domain.
const stream = client.beta.sessions.messages.stream({
session_id: session.id,
content: "My order #12345 is stuck — can you help?",
});
for await (const event of stream) {
if (event.type === "text") console.log(event.delta);
if (event.type === "tool_use") console.log("TOOL:", event.name);
if (event.type === "done") break;
}
Managed runs the tool loop server-side. You see streamed text, tool calls, and final response. You don't execute tools — Managed does (either built-in tools or via MCP).
Sessions are durable. A day later:
const next = await client.beta.sessions.messages.create({
session_id: session.id,
content: "Any update on my issue?",
});
Server-side compaction keeps context in budget. You don't manage history — it's stored and pruned automatically.
const sessions = await client.beta.sessions.list({
agent_id: agent.id,
metadata: { user_id: "u-42" },
limit: 50,
});
Use metadata filters to scope sessions by user, tenant, or workflow instance.
Tools are declared on the Agent. Managed executes them by:
tools: [
{
type: "url",
name: "ship_order",
description: "Ship an order",
input_schema: { /* ... */ },
url: "https://api.acme.com/tools/ship",
auth: { type: "bearer", token: "${ACME_TOKEN}" },
},
]
Your endpoint must return the tool result JSON. Managed handles retries and the loop.
Typically 5-15% more expensive than self-hosted agents in exchange for zero ops.
const events = await client.beta.sessions.events.list({ session_id, limit: 100 });
// Returns loop events: tool_use, tool_result, thinking, compaction, etc.
Every step is logged. You can audit, replay, and debug without running infrastructure.
Incremental:
Or parallel for critical flows — run both and A/B test.
development
Test skills for correct activation, content quality, and regression — both automated checks (frontmatter validity, lint) and manual verification (query-suite activation testing). Covers CI integration and how to catch skill regressions before users do. Use this skill when adding skills to a repo, setting up CI for a skill library, or debugging "the skill exists but doesn't work". Activate when: test skills, validate skills, skill CI, skill linting, skill activation test, skill regression.
documentation
Write the YAML frontmatter for a SKILL.md file so it activates reliably — name, description, and activation keywords that the model matches against. Covers length, tone, and the most common frontmatter mistakes. Use this skill when authoring a new skill, fixing a skill that isn't auto-activating, or reviewing skills for publication. Activate when: SKILL.md frontmatter, skill description, skill activation, skill YAML, write a skill, author a skill.
development
Design skills that fire at the right moment — neither over-eager (noise) nor under-eager (silent). Covers activation specificity, trigger phrases, disambiguation between overlapping skills, and debugging activation. Use this skill when multiple skills could fire on the same query, a skill never fires, or a skill fires too often. Activate when: skill won't activate, skill over-activates, overlapping skills, skill triggers, skill selection, skill disambiguation.
development
Structure SKILL.md content so the model reads just enough — concise summary up front, progressively deeper detail, examples on demand. Covers section ordering, length budgets, when to split into multiple skills. Use this skill when writing or refactoring a skill body, one skill has grown too long, or a skill is wordy but not useful. Activate when: SKILL.md structure, skill content, skill too long, split skill, progressive disclosure, skill body.