Single logo
  • Courses
  • Blog
  • About
Join on SkoolJoin on Skool

In this topic

Claude
  • Claude.ai Interface Tour: Every Control You Need on One Screen
  • The AI Fluency Model: Delegation, Description, Discernment and Diligence
  • Working With Claude: Pick the Surface, Match the Model, Keep the Context Clear
  • Claude's Four Entry Points: Choose Chat, Projects, Artifacts or Research Before You Type
  • What Claude Can Do: Extended Thinking, Web Search, Artifacts and File Analysis
  • Getting More From a Claude Chat: Steer the Conversation Instead of Starting Over
  • Claude Research Mode End to End: From One Prompt to a Cited Briefing
  • Claude's Capability Layer: When to Use Skills, Code Execution or Memory
  • Code Execution and File Creation in Claude: Calculated Numbers and a Real Excel File
  • Adding and Using Skills in Claude: Let Claude Pick the Skill, Then Teach It Your Format
  • Claude Memory, Curation and Incognito: Keep What Helps, Remove What Has Gone Stale
  • Claude Styles, Preferences and Project Instructions: Three Dials, Three Scopes
  • Claude Projects: Knowledge, Instructions and a Real Workspace You Set Up Once
  • Keeping a Claude Project Current and Connected: Refresh, Prune and Grant the Least
  • Claude Scheduled Tasks: Let Claude Work on a Schedule and Email You the Result
  • Claude Code and Claude for Chrome: What They Are and Who They Are For
  • Anatomy of a Good Prompt: Role, Context, Task, Format and Examples
  • Shaping Claude's Output: Format, Tone and Length in a Few Words
  • Iterating and Refining a Prompt: Read, Diagnose, Adjust, Repeat
  • Five Prompting Patterns for Work: Summarise, Extract, Rewrite, Classify and Draft
  • Why Evaluating AI Output Matters Most: Trust, Then Verify
  • Spotting AI Hallucinations and Fabrications: Four Tells and Where Risk Spikes
  • Fact-Checking Claude's Answers: Four Techniques and a Line-by-Line Claim Log
  • Judging AI Output Quality: Four Questions That Score Any Answer
  • Adapting AI Output for Your Audience: One Answer, Three Readers
  • When a Human Must Review AI Output Before It Ships
  • A Personal Validation Checklist for AI Output: Six Lines, Any Draft
  • Fitting Claude Into Real Work: Where It Helps and Where It Never Should
  • Breaking Big Tasks Into Steps With Claude: Small Asks, Checked Hand-offs
  • Designing a Repeatable Claude Workflow: A Reusable Weekly Report Template
  • Measuring If Claude Is Actually Working: One Number, Before and After
  • Communicating AI Value and Limitations to Stakeholders: The Honest Pitch
  • Data Privacy With Claude: What Never Goes in a Prompt, and How to Redact a Document Before You Paste It
  • Responsible AI Use and Transparency: Helpful, Honest, Harmless, and One Honest Line
  • Troubleshooting a Weak Claude Answer: Name the Cause, Fix One Thing, Then Make It Cheaper
  • CLAUDE.md, settings.json and Plugins: Which Claude Code File Advises, Which Enforces, Which Packages
  • Authoring a Claude Skill: SKILL.md, Frontmatter, Progressive Disclosure and the Description That Triggers It
  • One Change, Four Environments: Where a Claude Config Edit Lands in Dev, Staging, Prod and CI
  • Claude in the SDLC: Prompts in Git, a Change Gate by Path, a Claude Review That Advises and a Person Who Merges
  • Hooks That Block Destructive Actions: a PreToolUse Gate That Allows, Asks or Denies
  • Choosing a Claude Code Extension: Skill, Hook, Rules File, Subagent, Slash Command or Plugin
  • Rolling Out Claude Code to a Team: Settings Precedence, dontAsk in CI, a Hook for Every-Time Rules and a Plugin for Five Repos
  • A Claude Code Review Bot in CI: Headless -p, JSON Findings, Team Rules in Git and a Person on the Merge
  • Lab: Three Planted Bugs in a Claude Code CI Repo, a Permission Mode, a Plugin Path and an MCP Token Variable
  • Configuring MCP Servers in Claude Code: A Command or a URL, Three Scopes, and Three Moves When One Breaks
  • Claude Code's Built-in Tools: Read, Write, Edit, Bash, Grep and Glob, and When Each One Is the Right Pick
  • The CLAUDE.md Hierarchy: User, Project and Directory Files, How They Stack, and the Team Rule Stuck on One Laptop
  • Split a 600-Line CLAUDE.md: @import Lines, .claude/rules Files and Which One to Pick
  • Path-Specific Rules in Claude Code: paths Globs, When a Rule Loads and the Glob That Matches Nothing
  • Claude Code Slash Commands and Skills: Project vs User Scope, $ARGUMENTS, context: fork and allowed-tools
  • Iterative Refinement with Claude Code: Input/Output Examples, Tests First and the Interview Pattern
  • Claude Code Sessions: Resume by Name, Fork From a Baseline, or Start Fresh With a Summary Card
  • CI Reviews That Don't Repeat Themselves: Prior Findings, Existing Tests and Test Standards in CLAUDE.md
  • The Claude Messages API: Your First Call, Field by Field
  • Claude Tool Use: How tool_use and tool_result Work in the Messages API
  • Claude Client SDKs Wrap One REST API: Raw HTTP, Python, TypeScript and Async Calls Compared
  • Anthropic SDK Timeouts, Retries and Error Classes: Configure the Client Once, Then Give 429, 529, 400 and Timeouts Their Own Move
  • Claude Streaming Events: The Event Order, message_stop, Tool Arguments, Stop Reasons and a WebSocket Relay
  • Images, PDFs and Thinking Blocks in the Claude Messages API: Typed Blocks In, Typed Blocks Out
  • Getting Data Into Claude: PDF Documents, the Files API, Search Results and Citations
  • Opus, Sonnet or Haiku: Pick the Claude Model per Job, and Test the Request When a New Release Arrives
  • Adaptive Thinking and Effort in Claude: Two Dials, Set per Workload, and the Thinking Block You Must Pass Back
  • Claude Cost Tracking From usage: Count Before, Cap During, Read After, Then Find the Line That Drives the Bill
  • Claude Cache Breakpoints: Where to Put cache_control, How to Move It With the Chat, and Why the Reads Stay at Zero
  • Claude Message Batches or Real Time: Choose by Who Is Waiting, Match by custom_id, Resend Only the Failures
  • Calling Claude Through Amazon Bedrock, Google Cloud and Microsoft Foundry: Same Call, Different Door
  • The Life Cycle of a Claude App: Six Phases, a Model That Retires, and a Release Gate for Every Change
  • Pinning Claude Model IDs and Upgrading Safely: One Change at a Time, a Golden-Set Replay and a Staged Rollout
  • Content Boundaries and Schema Design for Claude: Fence the Input in a Tag, Let the Output Say I Don't Know
  • The Agentic Loop and stop_reason: Keep Turning on tool_use, Stop on end_turn, Cap the Turns
  • The Claude Agent SDK: query(), ClaudeAgentOptions and @tool, in Python and TypeScript
  • Fix the Agent: Four Broken Claude Agent SDK Configs, From the Symptom to the One Wrong Line
  • Claude Managed Agents: Cloud Sandbox, Self-Hosted Sandbox or Self-Hosted Service
  • Agent SDK Hooks for Deterministic Actions: PreToolUse, PostToolUse, and Four Hooks That Fail Silently
  • Memory and Context-Window Patterns for Claude Agents: Context Editing, Compaction and the Memory Tool
  • Reading an Agent Trace: Five Signatures, Five Missing Patterns, and How Long a Fact Must Live
  • Tool Descriptions for Claude: How Claude Picks a Tool, and How to Stop It Picking the Wrong One
  • Tool Input Schemas and Error Responses for Claude: Required Fields, Enums, is_error and a Retry Flag
  • Tool Response Shaping and a Lean Tool Set: Give Claude a Sticky Note, Not the Filing Cabinet
  • Fix the Tool Schema: Read the Trace, Fix the Card, Re-Run (Four Real Schema Bugs)
  • Client Tools, Server Tools and Approval Gates: Who Runs the Tool, and Who Says Yes First
  • Built-in Tool, Custom Tool, Skill or MCP Server? Pick the Lightest One That Fits
  • System Prompt or User Turn: Where Each Instruction Goes, and Output Limits Your Code Enforces
  • Refine the Prompt One Line at a Time, Then Clean and Fence the Customer's Text
  • Prompt Revision Driven by Evals: Name the Cause, Change One Thing, Rerun the Whole Suite
  • Long-Running Sessions: Compact, Prune, Isolate or Start Fresh, Decided by Naming the Failure
  • Context Isolation Through Subagents: Read the Logs Elsewhere, Keep One Line
  • Defensive Parsing of Claude Replies: Check the Stop Reason, Read the Block or the Text, Then Validate the Values
  • Full Context or Retrieval: Choose by Corpus Size, Cost and Freshness
  • Skepticism Toward Confident Output: Check the Quote, the Record and the Sum Before You Send
  • Debugging a Claude App: Three Error Types, the Recovery Each One Earns, and the First Failing Row
  • Six Ways a 200 Can Still Be Wrong: Hallucination, Refusal, Under-Acting, Context Loss, Format Drift and Inconsistency
  • Fix the Cause, Not the Symptom: Four Recovery Drills for an LLM App, Each Checked on a New Input
  • Integration Layer or Model Output? Three Taps and Three Questions to Find Where a Wrong Answer Lives
  • Which Test Layer Owns the Failure? Unit, Functional, Integration and End-to-End Tests for a Claude App
  • Designing an Overnight Document Pipeline on Claude: Batch Lane, Live Lane, a Cached Prefix and a custom_id Reconcile
  • Proving a Model Upgrade Is Ready: A Frozen Golden Set, a Calibrated Judge, the Right Layer and a Release Gate
  • From Requirement to Design for a Claude App: Eight Requirements, Five Elements and a Trace With No Gaps
  • Build a Claude Refund App: the Messages API, Two Tools, an MCP Server and a Hook in One Loop
  • Ship a Claude App: an Eval Gate, Two Guardrail Layers, a Cost Check From usage and a Pinned Model
  • Lab: a 30-Case Golden Set, a Calibrated Judge and a Per-Slice CI Gate on a Claude Refund App
  • Lab: Cut a Claude App's Bill by 62 Percent With Usage Data, Layered Cache Breakpoints and a Batch Job
  • Lab: Three Planted Bugs in a Claude App, a Vague Prompt, a Mistyped Tool Schema and a Broken Stream Handler
  • Lab: Three Planted Bugs in a Claude Code CI Repo, a Permission Mode, a Plugin Path and an MCP Token Variable
  • Lab: Harden a Claude App, an Uncalibrated Judge, a Retry Loop That Retries Everything and a Hook Matcher With a Gap
  • Lab: Turn a Claude App Into a Reusable Template, One Pinned Model Id, No Key in Code and Evals Built From Data
  • Building an MCP Server: Tools, Resources and Prompts in Python and TypeScript
  • MCP Transports: stdio or Streamable HTTP, and Who Starts the Server
  • Deploying and Authenticating an MCP Server: Environment Keys for stdio, Bearer Tokens and Scopes for HTTP
  • Validation-Retry Loops for Claude Extraction: Send Back the Exact Errors, and Stop When a Retry Cannot Help
  • Multi-Pass and Multi-Instance Code Review with Claude: A Fresh Reviewer, Per-File Passes and an Integration Pass
  • When a Claude Support Agent Should Escalate: Three Clear Triggers, Not Mood or a Confidence Score
  • Error Propagation Across Subagents: Retry Locally, Then Report the Failure, the Attempts and What You Found
  • Human Review and Confidence Calibration: Check Accuracy by Type and Field Before You Stop Looking
  • Provenance in Multi-Source Research: Keep Every Claim With Its Source and Date, and Show Conflicts Instead of Settling Them
  • Lab: An Extraction Pipeline With a Nullable Schema, Validation-Retry, a 100-Request Batch and Human Review
  • Lab: A Research Pipeline With Parallel Subagents, a Timeout That Keeps Its Partial Results, and a Report With Its Trail
  • Coordinator and Subagents: Decompose, Delegate, Check Coverage, and Call Only the Spokes You Need
  • Passing Context to Subagents: Nothing Is Inherited, So Put Findings, Goal and Criteria in the Prompt
  • Parallel Subagents: Several Task Calls in One Response, Every Result Back in One User Turn
  • Task Decomposition: a Fixed Prompt Chain With an Integration Pass, or a Dynamic Plan That Adapts
  • Prompt Guidance vs Programmatic Gates: Block the Refund Until the Customer Is Verified, Then Hand Off a Card That Stands Alone
  • Scoped Tools per Agent and tool_choice: Three to Five Tools per Role, a Shared One, and auto, any or a Forced Tool
  1. Blog
  2. /
  3. Claude
  4. /
  5. Building with the Claude API

Scoped Tools per Agent and tool_choice: Three to Five Tools per Role, a Shared One, and auto, any or a Forced Tool

A synthesis agent holding all fifteen tools reaches for web_search instead of writing the summary. Give each role three to five tools plus one shared check_fact, restrict them in the AgentDefinition, and set tool_choice to auto, any or a forced tool to match the job.

Chaand Sheikh

·27 November 2026Building with the Claude API

What you will learn

  • Split fifteen tools into small role scopes with one shared cross-role tool
  • Tell the tools list in an AgentDefinition (restricts) from allowedTools (only auto-approves)
  • Replace a generic tool like open_url with a constrained one that validates inside the tool
  • Use tool_choice auto, any and a forced tool, then go back to auto for the follow-up turn

Before you start

  • Claude tool use: tool_use and tool_result
  • Subagents in the Claude Agent SDK

A research team is built from AI agents, and the synthesis agent has one job: merge the findings into a summary. But we gave every agent every tool, fifteen of them, from web_search to send_email. The synthesis agent reaches for web_search instead of merging. That's outside its specialty, so it misuses the tool, and the summary is never written.

More tools means a harder choice, and a worse one. This lesson fixes that in two halves: first which tools each agent holds, then tool_choice, which controls whether Claude must call a tool at all.

A kitchen gives each station its own tools

The pastry station has a whisk, a piping bag and a rolling pin. The grill station has tongs, a grill brush and skewers. In the middle there's one shared thermometer that every station may use. The pastry chef never reaches for the grill. A few tools, the right ones, and fast choices.

Agents work the same way: scoped tools for each role, plus a few shared ones.

One agent with fifteen tools, or two scoped roles One agent, 15 tools web_search open_url load_report read_file list_folder write_file run_sql send_email post_chat make_chart summarize translate check_fact log_note hand_off wrong picks, slow choices Search agent 4 tools web_search load_report list_folder log_note Synthesis agent 3 tools summarize make_chart check_fact shared on purpose
Split by role: four tools and three, with one limited cross-role tool.

Three to five tools per role, and one shared tool

The exam guide puts it as 4-5 tools rather than 18; three is fine for a narrow role. The search agent gets four tools for searching and loading reports. The synthesis agent gets three.

check_fact sits in the synthesis scope on purpose. Checking a fact comes up often while writing a summary, so a limited cross-role tool saves a round trip. Anything harder, like real research, goes back through the coordinator instead of turning the synthesis agent into a second search agent.

scopes.py: the scopes as plain data

"""Give each agent only the tools its role needs."""
ALL_TOOLS = ["web_search", "open_url", "load_report", "read_file",
             "list_folder", "write_file", "run_sql", "send_email",
             "post_chat", "make_chart", "summarize", "translate",
             "check_fact", "log_note", "hand_off"]

SCOPES = {
    "search_agent": ["web_search", "load_report", "list_folder",
                     "log_note"],
    "synthesis_agent": ["summarize", "make_chart", "check_fact"],
}


def allowed(role, tool):
    return tool in SCOPES[role]


print(f"one agent with everything: {len(ALL_TOOLS)} tools")
for role, tools in SCOPES.items():
    print(f"{role}: {len(tools)} tools -> {', '.join(tools)}")
for role, tool in [("synthesis_agent", "web_search"),
                   ("synthesis_agent", "check_fact")]:
    ok = allowed(role, tool)
    verdict = "ok" if ok else "not in scope, hand_off"
    print(f"{role} asks for {tool}: {verdict}")

allowed() is a tiny scope check that runs before a tool does. Running python scopes.py prints:

one agent with everything: 15 tools
search_agent: 4 tools -> web_search, load_report, list_folder, log_note
synthesis_agent: 3 tools -> summarize, make_chart, check_fact
synthesis_agent asks for web_search: not in scope, hand_off
synthesis_agent asks for check_fact: ok

The synthesis agent's request for web_search is refused and handed off. check_fact is the shared tool, so that one is fine.

In the Agent SDK: tools restricts, allowedTools approves

In the Claude Agent SDK, you restrict a subagent with the tools list in its agent definition. The lecture's slide shows the contrast:

AgentDefinition(prompt=..., tools=["WebSearch"])   # restricts
allowed_tools=[...]   # only auto-approves, it never restricts

This one trips people up. allowedTools (allowed_tools in Python) decides which tools run without asking for permission. It doesn't take any tool away. If you want the synthesis agent to be unable to search, the scope goes in the tools list of its AgentDefinition. For more allowlist bugs, see fixing Claude Agent SDK configs.

open_url becomes load_report

A small scope still isn't enough if one tool in it can do anything. A generic open_url accepts any address: a news page, an admin payroll page, a report. Everything gets in.

A constrained load_report validates the link inside the tool. Of the same three requests, the news page and admin/payroll are refused, and only the approved reports/R-7 link passes. The agent can't wander, because the check isn't something the model has to remember. The same idea, applied to what a tool can read, change and send, is in agent blast radius and least privilege.

tool_choice: three ways to choose the call

The second half. The user asks: Summarize report R-7. The tool_choice field decides how much freedom Claude has.

The three tool_choice modes "auto" plain text or a tool Claude decides the default "any" must call some tool Claude picks which no plain chat "tool" + name must call read_document_info then back to auto
auto leaves it open, any guarantees a tool, forced names the tool.
  • {"type": "auto"} is the default. Claude may answer in text or call a tool.
  • {"type": "any"} means Claude must call some tool. It picks which one, but it can't just chat.
  • {"type": "tool", "name": "read_document_info"} is forced selection. Claude must call that tool first, and the follow-up turns continue normally.

One note from the lecture: some of the newest models don't accept forced tool choice (source: Claude docs, Define tools). On those, use auto with strict tools or structured outputs. The exam still asks about forced selection, so it's worth knowing. That's why the file below uses claude-haiku-5-5, which accepts it.

tool_choice.py: three calls, then a normal turn

from stand_in import make_client, TOOLS

client = make_client()
ASK = [{"role": "user", "content": "Summarize report R-7."}]
MODES = [{"type": "auto"},
         {"type": "any"},
         {"type": "tool", "name": "read_document_info"}]

for mode in MODES:
    reply = client.messages.create(
        model="claude-haiku-5-5", max_tokens=256,
        tools=TOOLS, tool_choice=mode, messages=ASK)
    first = reply.content[0]
    what = first.name if first.type == "tool_use" else "text only"
    print(f"{mode['type']:5} -> {what}")

# a forced first call, then the next turn continues normally
messages = ASK + [
    {"role": "assistant", "content": reply.content},
    {"role": "user", "content": [{
        "type": "tool_result", "tool_use_id": reply.content[0].id,
        "content": "title: R-7, 12 pages"}]}]
follow = client.messages.create(
    model="claude-haiku-5-5", max_tokens=256, tools=TOOLS,
    tool_choice={"type": "auto"}, messages=messages)
print("next turn, auto ->", follow.content[0].text)

tool_choice=mode is just one more argument to messages.create. After the loop, reply holds the forced call, so its tool_result goes back as usual, and the next turn sets tool_choice back to auto because later turns are normal. TOOLS holds two tools, read_document_info and find_sources.

The output comes from a stand-in model (stand_in.py, the real Anthropic SDK talking to an httpx.MockTransport), so no API key is needed. The stand-in imitates the three modes with a simple rule; with a real key in .env the same code calls Claude.

auto  -> text only
any   -> find_sources
tool  -> read_document_info
next turn, auto -> test model reply: got the details, ready for the next step.

Auto answered with text only. Any called a tool, of its own choosing. The forced mode called exactly read_document_info, and the next turn, on auto, gave a normal reply.

Common mistakes

  • Using allowedTools to restrict a subagent. It only auto-approves. Put the scope in the tools list of the AgentDefinition.
  • Giving every agent every tool "just in case". The synthesis agent picks web_search and the summary never gets written.
  • Leaving a generic tool in a small scope. open_url lets the agent reach any address. Validate inside a constrained tool instead.
  • Leaving tool_choice forced on every turn. Force the first call, then go back to auto for the follow-up.
  • Using auto when a tool call must happen. Auto may answer in text. Use any.

When the wrong tool gets picked from a well-scoped list, the description is usually the problem; see how Claude picks a tool.

Quick recap

The question needsThe setting
Guarantee a tool is calledtool_choice {"type": "any"}
This tool firstForced {"type": "tool", "name": ...}, then follow-up turns on auto
An agent misusing toolsScope three to five tools per role
A frequent small need across rolesOne limited shared tool, hard cases via the coordinator
Stop a subagent using a tooltools in its AgentDefinition, not allowedTools
A tool that can reach anythingA constrained tool that validates its input

An exam question may use other names, like fetch_url or extract_metadata. Read what the question needs, then pick the setting.

The tool scopes project, stand-in model and README for this lesson are in the community, free to join.

Try it yourself

Add a third role to SCOPES and print its count. Then change the forced tool in MODES to find_sources and predict the four printed lines before you run it.

Tried the exercise? Share your answer or ask a question.

The StudyEasy AI Community is free to join, with the lesson files, notebooks and code.

Join free on Skool

Keep going in Claude · 123 of 123

Previous
Prompt Guidance vs Programmatic Gates: Block the Refund Until the Customer Is Verified, Then Hand Off a Card That Stands Alone

Related course on Udemy

Claude Certified Architect - Foundations (CCAR-F) Exam Prep

Agentic loops, tools, MCP, Claude Code, prompts, structured output and context.View on Udemy ↗: Claude Certified Architect - Foundations (CCAR-F) 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.

On this page

  • A kitchen gives each station its own tools
  • Three to five tools per role, and one shared tool
  • scopes.py: the scopes as plain data
  • In the Agent SDK: tools restricts, allowedTools approves
  • open_url becomes load_report
  • tool_choice: three ways to choose the call
  • tool_choice.py: three calls, then a normal turn
  • Common mistakes
  • Quick recap
  • Try it yourself
Community · Free to join
Single logo

StudyEasy AI Community

Hosted onSkool

Learn AI engineering, share what you build, and connect with other learners.

  • Free resources: lesson files, notebooks and code

  • Ask questions and join engineering discussions

  • Meet real people learning and building with AI

Join free on Skool

Related course on Udemy

Claude Certified Architect - Foundations (CCAR-F) Exam Prep

Agentic loops, tools, MCP, Claude Code, prompts, structured output and context.View on Udemy ↗: Claude Certified Architect - Foundations (CCAR-F) Exam Prep (paid course, opens in a new tab)

Single logo

Empowering Education, One Course at a Time

About
About usContact us
Legal
Terms of UsePrivacy Policy

© 2026 StudyEasy Organization. All rights reserved.