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

In this topic

Claude
  • 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
  • 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
  1. Blog
  2. /
  3. Claude
  4. /
  5. Building with the Claude API

Fix the Tool Schema: Read the Trace, Fix the Card, Re-Run (Four Real Schema Bugs)

Four broken tool cards from a refund app: amount left out of required, an enum the backend doesn't accept, a phone typed as a number one level down, and two tools with the same description. Read the trace, fix the card, run it again.

Chaand Sheikh

·27 November 2026Building with the Claude API

What you will learn

  • Map a failing tool call trace to the part of the tool card that caused it
  • Fix a missing required field, a wrong enum and a wrong nested type
  • Separate two tools whose descriptions overlap
  • Explain why patching the handler leaves the bug in place

Before you start

  • Tool input schemas and error responses
  • Tool descriptions: how Claude picks a tool

A customer writes: refund order A-102, the full 120. The agent calls the refund tool, and the backend answers with an error: amount is required.

Claude never saw the backend's rules. It only read the tool card. So the card is where the fix goes. In this article we repair four broken cards from a refund app with one routine: read the trace, fix the schema, re-run.

A paper form at a shop counter

A customer fills in a paper form exactly as it is printed. If the form is wrong, the customer gets it wrong too:

  1. The form marks the amount as optional, so the customer leaves it out. No amount, no refund.
  2. The tick boxes offer low, normal and high. The desk only takes routine or urgent.
  3. The phone box says "number", so the leading zero disappears. The desk wants text.
  4. Two counters have the same sign: money back. Nobody knows which one to visit.

Those are the four bugs in this lesson. Fix the form, not the customer.

The routine: the trace names the part

Which trace points at which part of the card 1. Read the trace 2. Fix the schema 3. Re-run The trace says Fix this part amount is required the required list priority high is not routine or urgent the enum callback.phone must be a string the nested type the wrong tool was called the descriptions
Fix the part the trace names, then run the same request again until the trace is clean.

The Claude docs name the description and the input schema as what Claude reads, so those are the two places a tool-call bug can live on the card.

tools_broken.py: four cards, four bugs

ISSUE_REFUND = tool(
    "issue_refund",
    "Refund or cancel an order. Gives the money back.",
    {"order_id": {"type": "string"},
     "amount": {"type": "number"}},
    ["order_id"])

HAND_TO_HUMAN = tool(
    "hand_to_human",
    "Send the case to a person.",
    {"order_id": {"type": "string"},
     "priority": {"type": "string",
                  "enum": ["low", "normal", "high"]}},
    ["order_id", "priority"])

BOOK_CALLBACK = tool(
    "book_callback",
    "Book a call back to the customer.",
    {"callback": {"type": "object",
                  "properties": {
                      "phone": {"type": "number"}},
                  "required": ["phone"]}},
    ["callback"])

CANCEL_ORDER = tool(
    "cancel_order",
    "Cancel or refund an order. Gives the money back.",
    {"order_id": {"type": "string"}},
    ["order_id"])
  • Bug 1: issue_refund lists amount as a property but leaves it out of required, so it may be skipped.
  • Bug 2: the priority enum offers low, normal and high. The backend only knows routine and urgent.
  • Bug 3: inside the nested callback object, phone is a number, so the leading zero is lost. Because phone is required, it is always sent, and always wrong. The mistake hides one level down.
  • Bug 4: issue_refund and cancel_order have the same words in a different order. Nothing tells Claude which one to choose.

tools_fixed.py: each change answers one trace

ISSUE_REFUND = tool(
    "issue_refund",
    "Refunds a delivered order and returns a refund id. "
    "Not for orders not shipped yet: use cancel_order.",
    {"order_id": {"type": "string"},
     "amount": {"type": "number"}},
    ["order_id", "amount"])

HAND_TO_HUMAN = tool(
    "hand_to_human",
    "Send the case to a person.",
    {"order_id": {"type": "string"},
     "priority": {"type": "string",
                  "enum": ["routine", "urgent"]}},
    ["order_id", "priority"])

BOOK_CALLBACK = tool(
    "book_callback",
    "Book a call back to the customer.",
    {"callback": {"type": "object",
                  "properties": {
                      "phone": {"type": "string"}},
                  "required": ["phone"]}},
    ["callback"])

CANCEL_ORDER = tool(
    "cancel_order",
    "Cancels an order that has not shipped yet and "
    "returns the money. "
    "Not for delivered orders: use issue_refund.",
    {"order_id": {"type": "string"}},
    ["order_id"])

Fix 1 adds amount to required. Fix 2 sets the enum to the values the backend accepts. Fix 3 types the phone as a string. Fix 4 gives each refund tool its own job, delivered orders against orders not shipped yet, and a "Not for" line that names the other tool.

Run it: broken cards, then fixed ones

fix_run.py sends the same requests against both files. The model is a stand-in reader that follows each card exactly as written: it fills only the required fields, maps a word onto the enum, converts a "number" field to an integer, and picks a tool by shared words (a tie goes to the first tool). That is not how the real model works, but it makes every failure trace back to the schema, and it needs no API key.

1 broken  issue_refund {"order_id": "A-102"}
          ERROR amount is required
1 fixed   issue_refund {"order_id": "A-102", "amount": 120}
          OK refund sent: 120
2 broken  hand_to_human {"order_id": "A-103", "priority": "high"}
          ERROR priority high is not routine or urgent
2 fixed   hand_to_human {"order_id": "A-103", "priority": "urgent"}
          OK queued urgent
3 broken  book_callback {"callback": {"phone": 7700900123}}
          ERROR callback.phone must be a string, got int
3 fixed   book_callback {"callback": {"phone": "07700900123"}}
          OK call booked for 07700900123
4 broken  tie: issue_refund 4, cancel_order 4 -> issue_refund
          issue_refund {"order_id": "A-105"}
          ERROR A-105 has not been delivered
4 fixed   issue_refund ruled out, cancel_order picked
          cancel_order {"order_id": "A-105"}
          OK A-105 cancelled

Each broken line carries the clue. amount is required points at the required list. high is not routine or urgent points at the enum. must be a string, got int points at the nested type, and you can see the zero missing from 7700900123. And case 4 is a tie, 4 against 4, so the first tool listed won, which was the wrong one for an order still processing.

Break it: patch the handler instead

The tempting shortcut is to leave the card alone and map high to urgent in the handler. The run shows what happens:

patched handler: high is mapped to urgent
          urgent request   card sends high   -> OK queued urgent
          routine request  card sends normal -> ERROR priority normal is not routine or urgent
fixed card, no patch
          routine request  card sends routine -> OK queued routine

The urgent request works, but a routine request sends normal, and the backend refuses it. The card still offers low, normal and high, and Claude keeps choosing from that list. Fix the card, and the routine request goes through with no patch at all.

Common mistakes

Symptom in the traceWrong fixRight fix
A field is missingDefault it in the handlerAdd it to required
A value isn't allowedMap values in the handlerMake the enum match the backend
Wrong type in a nested fieldLook only at top-level propertiesCheck the nested object's types
The wrong tool is calledAdd more code around the callSay when to use each tool, and when not

Quick recap

StepWhat you do
ReadThe trace names the part of the card that failed
FixChange the required list, the enum, the type or the description
Re-runSend the same request again and check the trace is clean

The card is what Claude reads. A patch elsewhere leaves it wrong for the next request. For the parts of a good card in the first place, see tool input schemas and error responses.

Try it yourself

hand_to_human still has a one-line description, Send the case to a person. Write a fuller one with a purpose, an input example and a boundary, so it can't be confused with book_callback.

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 · 37 of 66

Previous
Tool Response Shaping and a Lean Tool Set: Give Claude a Sticky Note, Not the Filing Cabinet
Next post
Client Tools, Server Tools and Approval Gates: Who Runs the Tool, and Who Says Yes First

Related course on Udemy

Claude Certified Developer - Foundations (CCDV-F) Exam Prep

Build and ship Claude apps: the API, agents, tools and MCP, prompts, evals, security and model choice.View on Udemy ↗: Claude Certified Developer - Foundations (CCDV-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 paper form at a shop counter
  • The routine: the trace names the part
  • tools_broken.py: four cards, four bugs
  • tools_fixed.py: each change answers one trace
  • Run it: broken cards, then fixed ones
  • Break it: patch the handler instead
  • 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 Developer - Foundations (CCDV-F) Exam Prep

Build and ship Claude apps: the API, agents, tools and MCP, prompts, evals, security and model choice.View on Udemy ↗: Claude Certified Developer - Foundations (CCDV-F) Exam Prep (paid course, opens in a new tab)

Single logo

Empowering Education, One Course at a Time

About
About usContact usFAQs
Legal
Terms of ServicePrivacy Policy

© 2026 StudyEasy Organization. All rights reserved.