◉CLAUDE LABJP
●2.1.296 — Subagents can set their own autoCompactWindow, and an env var pins the model used by workflow agents●HAIKU 5.5 — Since 2.1.293 (Oct 7), claude-haiku-5-5 is the default Haiku model on the Anthropic API●SONNET 4.5 — Retires on the Claude API on 11/30, 47 days left. Migrate to Sonnet 5.5●Q&A — A write-up shows three places to look when a Mod draws nothing and reports no error●AGENTS.MD — One write-up explains how to split the entry points when Codex and Claude Code share a folder: AGENTS.md and CLAUDE.md●NEW — Approval prompts for "cd, git add, commit" every time: not a missing setting, but how it works●2.1.296 — Subagents can set their own autoCompactWindow, and an env var pins the model used by workflow agents●HAIKU 5.5 — Since 2.1.293 (Oct 7), claude-haiku-5-5 is the default Haiku model on the Anthropic API●SONNET 4.5 — Retires on the Claude API on 11/30, 47 days left. Migrate to Sonnet 5.5●Q&A — A write-up shows three places to look when a Mod draws nothing and reports no error●AGENTS.MD — One write-up explains how to split the entry points when Codex and Claude Code share a folder: AGENTS.md and CLAUDE.md●NEW — Approval prompts for "cd, git add, commit" every time: not a missing setting, but how it works
Articles/API & SDK
⬡ API & SDK/2026-07-11Advanced

Tightening Tool Schemas From the Arguments You See in Production

Record the arguments Claude actually passes to your tools in production, then use that distribution to add enums and patterns back into your JSON Schema. With logging code and before/after numbers.

Claude API127tool use5JSON Schemaoperations30observability21

✦ Premium Article

One morning a small notification tool was returning success while nothing was actually being sent.

The cause was an argument. My code branched on status being "done", but that day Claude was passing "完了", the Japanese word for "done." The schema only said status: string, so from the model's point of view "完了" was a perfectly valid string. Validation passed. The log said tool executed, and the branch quietly fell through.

As an indie developer running several apps at once — leaving small jobs like notifications and AdMob aggregation to Claude's tool calls — this kind of "the type is right but the meaning is wrong" gap tends to surface long after you've forgotten about it. Rejecting bad values at runtime is a reactive patch. What I want to describe here is the opposite move: observing the arguments themselves in production, then tightening the schema after the fact.

Loose schemas breed semantic drift

An argument typed only as string or number gives the model far too much latitude.

Depending on context, Claude might write "done" one day and "完了" the next, or put "high" in priority on Monday and 3 on Tuesday. Every one of those is valid JSON. And that is exactly why the gap between what the model emits and the closed set your code silently expects slips past type checking and lands in production.

Guarding with runtime validation alone keeps you a step behind. You reject, you retry, and back comes yet another spelling. Your validation-exception logs grow, but the root cause — the breadth of expression you granted the model — never shrinks.

The place to tighten is the entrance. Put an enum in the schema and the model can only choose from that set. A schema constraint bites harder than any instruction in the prompt.

First, record the arguments verbatim

To tighten anything, you first need to know what is actually arriving. Wrap your calls in a thin layer that drops each tool-use input block straight into a ledger.

import Anthropic from "@anthropic-ai/sdk";
import { appendFile } from "node:fs/promises";
 
const client = new Anthropic();
 
type ToolCallRecord = {
  ts: string;
  model: string;
  tool: string;
  input: Record<string, unknown>;
};
 
async function logToolCalls(model: string, message: Anthropic.Message) {
  const rows: ToolCallRecord[] = [];
  for (const block of message.content) {
    if (block.type === "tool_use") {
      rows.push({
        ts: new Date().toISOString(),
        model,
        tool: block.name,
        input: block.input as Record<string, unknown>,
      });
    }
  }
  if (rows.length === 0) return;
  // One JSON object per line: easy to aggregate, hard to corrupt on append
  const jsonl = rows.map((r) => JSON.stringify(r)).join("\n") + "\n";
  await appendFile("tool_calls.jsonl", jsonl);
}
 
const res = await client.messages.create({
  model: "claude-sonnet-5",
  max_tokens: 1024,
  tools: myTools,
  messages,
});
await logToolCalls("claude-sonnet-5", res);

The key is to store the values raw, without normalizing them. Normalize before recording and you erase the very spelling variance you set out to observe. The only exception is arguments that carry personal data, which you mask field by field before writing.

✦

Thank you for reading this far.

Continue Reading

What follows includes implementation code, benchmarks, and practical content we hope you'll find useful. This site runs without ads — server and development costs are supported entirely by members like you. If it's been helpful, we'd be truly grateful for your support.

WHAT YOU'LL LEARN
✦A thin wrapper that records every tool_use input block verbatim, tagged with model and timestamp
✦Analyzer code that derives enums, patterns, and numeric ranges from the observed argument distribution
✦A warn-only to soft-constraint to hard-constraint rollout, and how to spot the point where over-tightening triggers empty tool calls
Secure payment via Stripe · Cancel anytime
✦

Unlock This Article

Get full access to the rest of this article. Buy once, read anytime. This site is ad-free — your support goes directly toward keeping it running.

or
Unlock all articles with Membership →
Share

Thank You for Reading

Claude Lab is ad-free, supported entirely by members like you. We publish practical guides daily with implementation code, benchmarks, and production-ready patterns. If you've found it useful, we'd love to have you on board.

  • ✦Copy-paste ready implementation code
  • ✦New advanced guides published daily
  • ✦$5/mo or $15 for lifetime access
View Membership →

Related Articles

⬡ API & SDK2026-08-30
Read the Catalog Your CLI Already Ships Before Bulk-Replacing Model IDs
A newer generation makes older model IDs look stale. Here is how to pull the catalog embedded in your installed binary, sort every reference into matched, date-mismatched, and malformed, and stop the replacement that would break working IDs.
⬡ API & SDK2026-10-13
Haiku 5.5 is cheaper per token, but your bill jumps fivefold past about 77k Haiku 4.5 tokens
On the price sheet, Haiku 5.5 costs roughly a tenth of Haiku 4.5. But the same text becomes about 30% more tokens, and a prompt over 100k tokens is billed at five times the rate. Here is the boundary in Haiku 4.5 terms, a script I actually ran, and the changes that return a 400.
⬡ API & SDK2026-10-08
Before Sonnet 4.5 retires, one script to find the arguments that will return a 400
claude-sonnet-4-5 retires on November 30. Swapping the model ID is not enough: budget_tokens, prefill, and tool_choice will fail. Here is a scanner built from the official migration guide, its real output, and the order I would fix things in.
📚RECOMMENDED BOOKS
Build a Large Language Model (From Scratch)
Sebastian Raschka
LLM Dev
Prompt Engineering for LLMs
Berryman & Ziegler
Prompting
AI Engineering
Chip Huyen
AI Eng
* Contains affiliate links