PROGRAM ZERO 18-month live AI, LLM & full-stack programme · ₹89,999 or ₹7,500/month · Starts 9 January 2027
Explore Program Zero →
Careers Ninza — business and startup leadership training
JOIN ZERO NINZA KIDS
JOIN ZERO NINZA KIDS
See all programs → Free live masterclass → Guides & articles → Newsletter →
Careers Ninza
AI & AUTOMATION 6 min read · Updated 2 November 2026

Building agents with the Claude Agent SDK: the loop, tools, evaluation and guardrails

The Claude Agent SDK gives developers the building blocks behind Claude Code to create agents that plan, use tools and work through multi-step tasks. This guide explains the agent loop, tool design, permissions, evaluation and a worked document-processing agent.

CN
Careers Ninza AI faculty
Careers Ninza · Kolkata, India
Learn this live in our Claude AI Mastery Part 2 course

The Claude Agent SDK packages the agent framework that powers Claude Code so developers can build their own agents: programs where Claude plans, calls tools, reads results and continues until a task is done, within permissions you set. Good agents have narrow goals, well-designed tools, controlled context, human checkpoints for risky actions and an evaluation set that proves they work.

Agents are session thirteen of Claude AI Mastery Part 2. For a no-code approach to agents with n8n, see our no-code agent guide; this post is for people writing code.

What is the agent loop?

1The agent receives a goal and context.
2Claude decides the next step: answer, or call a tool with specific inputs.
3Your code runs the tool and returns the result.
4Claude reads the result and decides the next step.
5The loop continues until the goal is met, a limit is reached or a human is needed.

The SDK handles much of this loop, plus context management, tool execution and permissions, so you focus on the tools and rules specific to your business. See the Agent SDK documentation for current languages, features and examples.

How should tools be designed?

PrincipleExample
One clear job per toolget_shipment_status, not do_logistics
Descriptive names and descriptions"Use when the user asks about a shipment; requires container number."
Strict input schemasContainer number pattern, date formats
Useful, compact outputsReturn the fields needed, not a full database row
Read and write separatedLookups freely; updates need approval
Clear errors"Container not found" rather than a stack trace

How do you manage context?

Agents can fill their context with long tool outputs and conversation history. Keep tool results concise, summarise earlier steps when tasks are long, load reference documents only when needed and use subagents for side tasks so the main agent stays focused. Good context management improves both accuracy and cost.

A worked example: a vendor certificate checking agent

A Pune engineering company receives material test certificates from suppliers and must check them against purchase specifications. The agent:

—Reads each new certificate PDF from a folder.
—Calls a tool to fetch the purchase order specification (grade, chemical composition limits, mechanical properties).
—Extracts values from the certificate and compares them with limits.
—Calls a tool to log results, marking pass, fail or unclear.
—For failures and unclear cases, drafts an email to the supplier for a quality engineer to approve.

Every action that leaves the company (supplier emails) requires human approval; everything internal is logged. Engineers now review exceptions instead of reading every certificate.

Illustration: certificates per day handled by one quality engineer (sample plant)
Manual checkingabout 25
With agent pre-checksabout 90, reviewing exceptions

Source: Careers Ninza classroom case; illustrative.

How do you evaluate an agent?

1Collect 50 to 100 real cases with expected outcomes, including edge cases and bad inputs.
2Define success: correct decision, correct tool calls, no unsafe actions, within cost and time limits.
3Run the set automatically after every change to prompts, tools or models.
4Track failures by type and fix the biggest categories first.
5Monitor live runs and add new failure cases to the set.

Treat inputs the agent reads (documents, emails, web pages) as untrusted. They may contain instructions designed to manipulate it. Limit tool permissions, require approval for high-impact actions and check outputs. Our guardrails guide covers this in depth.

Careers Ninza is an independent training institute. We are not affiliated with, sponsored by or endorsed by Anthropic, and our certificates are not Anthropic certifications. Claude is a trademark of Anthropic. Product features and plans change often; check claude.com for current details.

When should you use the SDK instead of a no-code tool?

SituationBetter choice
Simple workflows with standard appsNo-code (n8n, Make)
Custom logic, codebase or file-heavy workAgent SDK
Agents embedded in your own productAgent SDK or API
Team without developersNo-code, with Claude for Work features

What are the limits?

Agents are slower and more expensive than single calls, and they fail in more complicated ways. Many tasks are better as fixed workflows with one AI step. Build agents where the path truly varies and the value justifies the engineering and monitoring effort.

How should permissions and approvals be configured?

The SDK lets you control which tools an agent may use and whether actions need approval. A sensible starting configuration for business agents:

Action typeDefault setting
Read internal data through scoped toolsAllowed
Write to internal logs or draftsAllowed, logged
Change records in business systemsRequires approval at first
Send anything outside the companyAlways requires approval
Run shell commands or access the file system broadlyDisabled unless essential and sandboxed

As evaluation proves reliability for a specific action, you can relax approval for low-risk cases, while keeping logs and spot checks.

How do you control cost and runaway loops?

—Set a maximum number of turns or tool calls per task.
—Set token and time budgets per run, and alerts on daily spend.
—Use smaller models for routine sub-steps and larger ones only where reasoning matters.
—Cache stable context, such as policies, with prompt caching.
—Stop and escalate when the agent repeats the same tool call without progress.

How do agents connect to company systems?

Tools can call your APIs directly, or you can expose systems through MCP servers so the same connector works for agents, Claude apps and Claude Code. MCP is especially useful when several teams build agents on the same systems, because access rules live in one place. Session twelve of Part 2 covers building a simple MCP server; session thirteen puts it inside an agent.

The capstone in Part 2 often combines all three: an agent built with the SDK, using an MCP connector to a sample company database, with evaluation and approval steps, deployed and demonstrated to the batch.

KEY TAKEAWAYS

—Build agents only where the path genuinely varies.
—Design narrow tools with clear descriptions and strict inputs.
—Require approval for actions that change records or leave the company.
—Set turn, token and time limits to control cost.
—Evaluate with real cases after every change and monitor live runs.

What to do this week

1Pick one multi-step task where the path genuinely varies.
2List the tools the agent would need and mark each as read or write.
3Collect 30 real examples with expected outcomes for your first evaluation set.
4Decide which actions always need human approval.
5Build the smallest version that handles the most common case.

Our Claude AI Mastery Part 2 batches run live online, so the same class reaches learners and business owners in metros such as Chennai, Pune, Ahmedabad, Bengaluru and Kolkata, growing cities such as Ludhiana, Nagpur, Kochi, Bhubaneswar and Vadodara, and smaller industrial towns such as Morbi, Jalandhar, Hosur, Asansol and Kota, at the same fee. Each city page explains how local businesses use Claude agents, for example in Ludhiana, Kochi, Kota.

Learn this live: Claude AI Mastery Part 2

Build agents with the Claude Agent SDK, tools, MCP and evaluation, and demo a deployed capstone project. 30 live hours, ₹29,999, after Part 1.

SHORT-TERM COURSE · LIVE ONLINE
Claude AI Mastery Part 2

Build, deploy and maintain software, automations and agents with Claude Code, the Claude API and MCP. Levels 6 and 7, for developers and ambitious non-programmers who have completed Part 1.

₹29,999 · single payment30 hoursLive, mentor-ledCertificate on completion

Frequently asked questions

What is the Claude Agent SDK?+

It is a developer framework from Anthropic that provides the agent building blocks behind Claude Code, such as the agent loop, tool execution, context management and permissions, for building custom agents.

What can I build with the Agent SDK?+

Agents that work through multi-step tasks using tools, such as document checking, research, support triage, internal assistants and coding helpers, with human approval for risky actions.

Do I need to know programming to use the Agent SDK?+

Yes, basic programming in a supported language is needed. Non-programmers can build agents with no-code tools such as n8n instead.

How do I test an AI agent?+

Build an evaluation set of real cases with expected outcomes, define success criteria including safety, run it after every change and monitor live behaviour.

How do I keep an agent safe?+

Give it narrow goals and least-privilege tools, separate read and write actions, require human approval for high-impact steps, treat inputs as untrusted and log everything.

Where can I learn the Claude Agent SDK in India?+

Careers Ninza Claude AI Mastery Part 2 covers the API, tools, retrieval, MCP and agents with the Agent SDK. 30 live hours for ₹29,999, after Part 1. Independent of Anthropic.

Related reading

AI & AUTOMATION Rolling Out Claude Across an Indian Company: Pilots, Governance, Training and ROI Buying licences is the easy part of an AI rollout. This guide covers how Indian companies should pilot Claude, set governance and data rules, train people by role, build shared Skills and connectors, control cost and measure real value. 6 min read AI & AUTOMATION AI Automation for HR and Recruitment: Screening, Onboarding and Employee Questions HR teams spend hours on repetitive tasks: sorting CVs, scheduling interviews, onboarding paperwork and answering the same policy questions. This guide shows practical AI automations for Indian HR teams, with fairness and privacy safeguards. 6 min read AI & AUTOMATION Claude for Small Business Owners in India: 20 Practical Uses That Save Time and Money Owners of Indian MSMEs wear every hat: sales, accounts, HR, marketing and operations. This guide lists 20 practical ways Claude helps, from quotations and GST-ready summaries to job descriptions and customer replies, with safety rules and a plan to start. 6 min read

We teach this, live

Every article here comes from something we teach. Sit in on a free masterclass and judge the mentors yourself.