Choosing the Claude Build Stack: Client SDK, Agent SDK, Claude Code Headless or Managed Agents
Five teams build a claims agent, and each gets a different stack. Ask who runs the loop, then the team's language, then compliance and data custody, then the surface. A small function in code makes the pick.
What you will learn
- Place the four Claude build stacks on one axis: who runs the loop
- Keep entry point, build-time interface and delivery route as three separate choices
- Pick a stack per team from four facts: loop, compliance, hosting and language
- Compare runtimes on hosting, session state, sandboxing and data custody, and avoid hosted by default
Before you start
- Claude client SDKs wrap the REST API
- What an agent loop is
Picture a team about to build an agent with Claude. Before anyone writes a line of code, one question needs settling: who runs the loop? Client SDKs, the Agent SDK, Claude Code headless and Managed Agents all answer it differently. In this article you choose between them like an architect.
Four stacks on one axis
- Client SDKs and the ant CLI. Seven languages (Python, TypeScript, C#, Go, Java, PHP and Ruby), plus the
antcommand-line tool for shell scripting. You send each request and handle each response, including the stop reason and the usage. The tool loop is yours to write, or you can try the tool runner, in beta. Most control; you build and run the loop. See Claude client SDKs wrap the REST API. - Agent SDK. Claude Code's agent loop as a library, in Python and TypeScript, running in your own process on your own hosting. Built-in tools, hooks, permissions and sessions. More in the Claude Agent SDK.
- Claude Code headless. For a team that writes Java or Go: run the Claude Code command line as a subprocess, with the print flag (
claude -p) and JSON output. Either way, the runtime is self-hosted. - Managed Agents, in beta. Your app sends events and reads results as they stream back. Inside Anthropic's infrastructure sit the harness (the agent loop) and a sandbox, which can also be self-hosted. See Claude Managed Agents hosting.
Below the line sit libraries and integrations that put Claude inside another framework's API. They aren't general Messages API clients. For when a framework helps, see what LangChain is for.
Cook, meal kit or caterer
Think about getting dinner on the table. Cook from scratch: you buy everything and write every step. That's the client SDK. A meal kit: the parts come in the box, and you cook in your own kitchen. That's the Agent SDK. A caterer: their kitchen, their staff, you send an order and get the result. That's Managed Agents. Same dinner; the difference is who works in which kitchen.
Three layers, three choices
The choice has three separate layers. Settle each one on its own:
- Entry point: how the work arrives. A chat app, a nightly job, a CI step, a claims form.
- Build-time interface: what you code against. The client SDK, the Agent SDK, Claude Code headless or Managed Agents.
- Delivery route: where the model is served. The Claude API, Amazon Bedrock, Claude Platform on AWS, Microsoft Foundry, or Claude Models on Google Cloud (older material says Vertex AI).
How the delivery route is chosen under residency and compliance is in which requirement binds.
Five teams, one question
Five teams each build a claims agent: a Go team with a custom pipeline, a Python team that wants Claude Code's tools, a Java team that wants an agent loop, a night-jobs team that wants a hosted harness, and a clinic team with health data. One answer for everyone would be a bad bet. Their languages differ, and so do their rules.
The decision in code
The project runs against a stand-in: the Anthropic SDK on an httpx mock transport with one scripted reply, so no API key is needed and the reply shows the design, not a real model's quality. First, the client SDK way, from client_call.py: you send the request and read the stop_reason yourself.
"""The client SDK way: we send the request, we read the stop_reason, we own the loop."""
from stand_in import MODEL, make_client
def triage(claim_text, client):
reply = client.messages.create(model=MODEL, max_tokens=256,
messages=[{"role": "user", "content": claim_text}])
return reply.stop_reason, reply.content[0].text
Then stack_picker.py turns four facts about a team into one of four stacks. The rules come from the Claude docs pages on SDKs, the Agent SDK and Managed Agents:
"""Pick a build stack from four facts about a team."""
MANAGED_PLATFORMS = {
"Claude API",
"Claude Platform on AWS",
"Claude Models on Google Cloud (Anthropic managed)",
}
def pick(team):
if not team["want_agent_loop"]:
return ("Client SDK",
"we send each request and own the loop")
if team["compliance"] in ("ZDR", "HIPAA"):
return ("Agent SDK",
"loop stays in our process, "
"hosted harness not eligible")
if (team["hosted"]
and team["platform"] in MANAGED_PLATFORMS):
return ("Managed Agents (beta)",
"Anthropic hosts the harness")
if team["language"] in ("Python", "TypeScript"):
return ("Agent SDK",
"the loop runs in our own process")
return ("Claude Code headless",
"run claude -p as a subprocess")
- No agent loop wanted: the client SDK.
- Zero data retention (ZDR) or HIPAA: the hosted harness is out.
- A hosted harness on a supported platform: Managed Agents. Per the lecture, it's offered on the Claude API, Claude Platform on AWS and the Anthropic-managed Claude Models on Google Cloud.
- A Python or TypeScript team: the Agent SDK. Anyone else: Claude Code headless.
The recorded run:
client call -> stop_reason end_turn | test model reply: claim C-7 looks complete, send it to review.
stack picks
Go team -> Client SDK | we send each request and own the loop
Python team -> Agent SDK | the loop runs in our own process
Java team -> Claude Code headless | run claude -p as a subprocess
Night-jobs team -> Managed Agents (beta) | Anthropic hosts the harness
Clinic team -> Agent SDK | loop stays in our process, hosted harness not eligible
Same question, five teams, four different stacks. The clinic team has HIPAA data, so the loop stays in its own process.
One table, three runtimes
| Runtime | Hosting | Session state | Sandboxing | Data custody |
|---|---|---|---|---|
| Messages API loop | Your code decides | You keep the history | Your code decides where tools run | Your own setup decides |
| Self-hosted Agent SDK or headless Claude Code | You operate the process | Sessions live in your process | You set the permissions | Your own setup decides |
| Managed Agents (beta) | Anthropic hosts it | The service keeps sessions until you delete them | Anthropic's cloud or self-hosted | The catch: per the docs, not HIPAA-eligible, and no ZDR unless you self-host the whole service |
Every cell is a trade-off, and feature availability follows the surface as well. Managed Agents suits long-running and asynchronous work; check the data rules first.
The trap: hosted by default
A clinic team has health data. They reason that hosted means less to run, so they pick Managed Agents. It breaks: Managed Agents isn't eligible for HIPAA, and the Google-managed offering of Claude Models on Google Cloud doesn't have it at all. The fix is to read the data custody column first, then ask who should run the loop. Less to run is a benefit. It's never the first filter.
A worked case
A logistics team writes Go. It wants Claude Code's file and shell tools, and it wants session history kept on its own servers.
The answer order is always the same: who runs the loop, then the team's language, then compliance and data custody, then the surface and hosting.
Quick recap
| Stack | Pick it when |
|---|---|
| Client SDK | You want to write the loop yourself, or need no loop |
| Agent SDK | You want Claude Code's loop in your own Python or TypeScript process |
| Claude Code headless | Same, from another language, as a subprocess |
| Managed Agents (beta) | You want a hosted harness and the data rules allow it |
The project files for this lesson are in the community, free to join.
Try it yourself
Add a sixth team: a TypeScript team on Amazon Bedrock that wants a hosted harness and has no compliance rule. Trace it through pick() before you run it. Which rule catches it, and why is Managed Agents not the answer here? Then think about a Java clinic team: what does pick() return, and does that fit a Java codebase?
Related course on Udemy
Claude Certified Architect - Professional (CCAR-P) Exam Prep
Architecting with Claude: design, models, context, integration, evals, governance and stakeholders.View on Udemy ↗: Claude Certified Architect - Professional (CCAR-P) 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.
