# 25.8 Strict tool use or structured output (/building-ai-workers/prompts-and-structured-output/strict-tool-use-or-structured-output)

---
type: Document
title: "25.8 Strict tool use or structured output"
description: "A strict tool for an action and a structured output for data, what forcing a tool does, and how the code knows the tool was called."
status: stable
order: 325.08
ksor:
  owner: team:panaversity
  audience:
    - public
  approval:
    by: process:panaversity
    at: 2026-11-30T00:02:23Z
chapter: '25'
part: III
expert_status: co-build
concepts: [ "25.8" ]
last_verified: '2026-11-29'
sources:
  - id: anthropic-structured-outputs
    title: Structured outputs (verified 2026-11-29)
    resource: https://platform.claude.com/docs/en/build-with-claude/structured-outputs
  - id: anthropic-prompting-haiku-5-5
    title: Prompting Claude Haiku 5.5 (Claude Platform docs, verified 2026-11-29)
    resource: https://platform.claude.com/docs/en/build-with-claude/prompt-engineering/prompting-claude-haiku-5-5
  - id: anthropic-strict-tool-use
    title: Strict tool use (Claude Platform docs, verified 2026-11-29)
    resource: https://platform.claude.com/docs/en/agents-and-tools/tool-use/strict-tool-use
  - id: anthropic-define-tools
    title: 'Define tools: forcing tool use (Claude Platform docs, verified 2026-11-29)'
    resource: https://platform.claude.com/docs/en/agents-and-tools/tool-use/define-tools
  - id: anthropic-cookbook-extracting-json
    title: Extracting structured JSON using Claude and tool use (Claude Cookbook, scanned 2026-11-29)
    resource: https://platform.claude.com/cookbook/tool-use-extracting-structured-json
generated:
  at: 2026-11-30T00:02:23Z
  by: esl-rewrite/1.2.0+ksor.1
trust_tier: unverified
build_id: sha256:cc6fd9ac5f72207d4365ecbda63d87d1b64f99e05519b358a45b9f5d9bfd6f8f
dirty: true
ksor_version: 0.0.60
---

**In everyday life.** In a restaurant, a waiter writes two kinds of paper. The order slip goes to the kitchen, and something is cooked because of it. The bill comes to your table at the end, and nothing is cooked because of it: it is a record of what happened. A waiter who wanted a written record would not send the kitchen an order for a dish nobody will eat.

**What you will learn.** You practice this in Lab 25, Task 3.

- What is the difference between strict tool use and a structured output?
- What happens when I force a tool?
- If I cannot force the tool, how do I know it was called?
- What does each choice cost?

**Why it matters.** The API can hold a shape in two places. Choose the wrong one on a current model, and every request is rejected.

**At work.** The extraction step now uses both kinds. When the model calls `get_invoice`, it is asking the portal's code to do something: fetch one invoice. When it returns the fields, it is handing over data for the due-date code. The builder has seen an older way to get the data, in tutorials. You define a tool whose inputs are the invoice's fields, force the model to call it, and read the inputs as the answer. The builder tries it on the lab's model, `claude-sonnet-5-5`, and the API rejects the request.

### What is the difference between strict tool use and a structured output?

**Strict tool use holds the inputs of a tool call, and a structured output holds the final answer.** For strict tool use, you add `"strict": true` to the tool's definition, beside its name, description and input schema. The API then guarantees two things: the inputs follow the tool's schema, and the tool's name is always one you defined.[^anthropic-strict-tool-use] [21.2](../agent-loop-by-hand/a-tool-is-a-name-a-description-and-a-schema.md) taught it.

A structured output is 25.7's subject. The two are different features with different switches, and one request can use both.[^anthropic-structured-outputs]

| You want | Use | What the API holds |
| --- | --- | --- |
| The model to ask your code to do something: fetch, look up, write | Strict tool use: `"strict": true` on the tool | The tool's name and its inputs |
| The model's final answer as data your code will read | A structured output: `output_config.format` | The text of the final answer |

The schema of a structured output applies only to what the model writes as its answer. It does not apply to tool calls, to tool results or to the model's thinking.[^anthropic-structured-outputs] So the two do not overlap. In the extraction step, `get_invoice` is a strict tool, and the invoice's fields are a structured output.

Ask one question to choose: will something happen because of this JSON, or will code only read it? An action is a tool. Data is the answer.

### What happens when I force a tool?

**On current Claude models the API rejects the request.** [21.2](../agent-loop-by-hand/a-tool-is-a-name-a-description-and-a-schema.md) taught tool choice. The models are Claude Fable 5.2, Claude Mythos 5.2, Claude Opus 5.5, Claude Sonnet 5.5, Claude Fable 5.1 and Claude Mythos 5.1. On these, a request whose tool choice is `any` or `tool`, the two values that force a call, returns a 400 error.[^anthropic-define-tools] The documentation says what to do on these models. Use `auto` with strict tool use, or use structured outputs when you need an answer in a fixed JSON shape.[^anthropic-define-tools]

Other models, such as Claude Opus 5 and Claude Haiku 5.5, accept a forced tool, but a forced call skips thinking.[^anthropic-define-tools] There is one more case. With manual extended thinking, a setting where your request turns the model's thinking on and sets its size, `any` and `tool` are rejected too.[^anthropic-define-tools]

You will still meet the old way. One of Anthropic's own cookbook examples for extracting JSON still forces a tool, on Claude Haiku 5.5, where it is accepted.[^anthropic-cookbook-extracting-json] Read such an example as written for the model it names.

### If I cannot force the tool, how do I know it was called?

**Your code checks.** With `auto`, the model decides whether to call `get_invoice`. Anthropic's notes for Claude Haiku 5.5 name one risk. With thinking off, the model might skip a tool call it needs when an output format is also set.[^anthropic-prompting-haiku-5-5] A person who read an answer would have asked "did you read the invoice?" The code asks the same thing on purpose: an answer that arrives with no `get_invoice` call before it is not accepted, and goes to `needs_review`. It is stopped at the first gate, the one that reads the stop reason. When the stop reason says the model has finished, the code looks for the call before it parses anything (25.10).

### What does each choice cost?

- **Strict tools and structured outputs share limits.** A request may carry at most 20 strict tools, and a schema with many optional fields can be refused as too complex.[^anthropic-structured-outputs] The extraction's one tool and eight fields are far inside these limits.
- **`auto` is a request, not an order.** You pay for it with the check above.
- **Forcing, where it is accepted, costs the thinking.** On a model such as Claude Haiku 5.5 a forced call is allowed and fair for a simple job. It also ties the code to that model, because a current model rejects the same request (above).

A strict `get_invoice` call always has a well-formed invoice number. Whether that invoice exists is for the tool's own code to check, as in 21.2. The same limit for the answer is 25.9's subject.

**The operating rule:** an action is a strict tool, and data is a structured output. Leave tool choice on `auto`, and let your code check that the tool was called.

**Do this now.** Ask your coding agent to find every forced tool in your code. Copy this line:

> List every request our code sends to a model. For each, say which model it names, whether it sets a tool choice and to what, and whether it uses a tool only to get JSON back. Mark each request that would return a 400 error on claude-sonnet-5-5. Change nothing.

Check: for every marked request, say whether its JSON is an action or data. Each one that is data should become a structured output.

[^anthropic-strict-tool-use]: Strict tool use, Anthropic.
[^anthropic-structured-outputs]: Structured outputs, Anthropic.
[^anthropic-define-tools]: Define tools: forcing tool use, Anthropic.
[^anthropic-cookbook-extracting-json]: Extracting structured JSON using Claude and tool use, Claude Cookbook.
[^anthropic-prompting-haiku-5-5]: Prompting Claude Haiku 5.5, Anthropic.
