Claude Agent SDK vs rolling your own tool loop: which one for your product? A developer published a decision guide comparing three ways to build a Claude-powered agent: a hand-written tool loop using client.messages.create(), the beta client.beta.messages.toolRunner() helper in @anthropic-ai/sdk, and the @anthropic-ai/claude-agent-sdk, which bundles the Claude Code harness with built-in file, shell and web tools plus permissions, hooks, subagents and sessions. The guide includes runnable TypeScript for each option, token usage measured against the live API on 2026-11-03 with @anthropic-ai/sdk 1.4.0 and @anthropic-ai/claude-agent-sdk 0.3.317, and a table mapping product types to an option. It stresses that the Tool Runner and the Agent SDK are distinct products and that neither hosts anything for the developer. You have decided your product needs an agent: Claude should call tools, look at the results and decide what to do next. Before you write any code there is a choice that shapes everything after it. Do you write the tool loop yourself, let the Anthropic SDK run it for you, or embed the Claude Agent SDK and get Claude Code's whole harness as a library? This post is a decision guide, not a review. Each option is the right answer for some products. Below is runnable TypeScript for all three, what each one leaves you in control of, the token usage we measured when running them, and a table at the end that maps "what you are building" to an option. Facts and code were checked against the official docs and run against the live API on 2026-11-03 with @anthropic-ai/sdk 1.4.0 and @anthropic-ai/claude-agent-sdk 0.3.317. client.messages.create , check stop reason , run the tools Claude asked for, send the results back, repeat. About 50 lines. You own every request. client.beta.messages.toolRunner runs the loop. You write tool functions, it calls them and feeds the results back until Claude is done. It is a beta helper. @anthropic-ai/claude-agent-sdk . It ships built-in tools for reading, writing and editing files, running shell commands and searching the web, plus permissions, hooks, subagents and sessions. You call query with a prompt and options. The common confusion: the Tool Runner and the Agent SDK sound alike but are different products. The Tool Runner lives in the regular API SDK and only loops over tools you define. The Agent SDK runs the Claude Code binary the npm package bundles it with its own tools and its own system prompt. Neither hosts anything for you; both run wherever your code runs. The example is a support agent with one tool that looks up an order. In a real product the tool would query your database. python import Anthropic from "@anthropic-ai/sdk"; const client = new Anthropic ; const MODEL = process.env.MODEL ?? "claude-sonnet-5-5"; const tools: Anthropic.Tool = { name: "get order", description: "Look up an order by id. Returns status and total in USD.", input schema: { type: "object", properties: { order id: { type: "string" } }, required: "order id" , additionalProperties: false, }, strict: true, }, ; async function runTool name: string, input: unknown : Promise