Home / Claude Certified Architect – Foundations / Objective 4.3

Domain 4: Prompt Engineering & Structured Output · 20% of the exam · Full exam outline

4.3 Enforce structured output using tool use and JSON schemas

What this objective covers

Tool use (tool_use) with JSON schemas as the most reliable approach for guaranteed schema-compliant structured output, eliminating JSON syntax errors. The distinction between tool_choice: "auto" (model may return text instead of calling a tool), "any" (model must call a tool but can choose which), and forced tool selection (model must call a specific named tool). That strict JSON schemas via tool use eliminate syntax errors but do not prevent semantic errors (e.g., line items that don't sum to total, values in wrong fields). Schema design considerations: required vs optional fields, enum fields with "other" + detail string patterns for extensible categories. Defining extraction tools with JSON schemas as input parameters and extracting structured data from the tool_use response. Setting tool_choice: "any" to guarantee structured output when multiple extraction schemas exist and the document type is unknown. Forcing a specific tool with tool_choice: {"type": "tool", "name": "extract_metadata"} to ensure a particular extraction runs before enrichment steps. Designing schema fields as optional (nullable) when source documents may not contain the information, preventing the model from fabricating values to satisfy required fields. Adding enum values like "unclear" for ambiguous cases and "other" + detail fields for extensible categorization. Including format normalization rules in prompts alongside strict output schemas to handle inconsistent source formatting.

Practice questions

Question 1easy

An extraction script sends one tool definition and leaves tool_choice unset. Most responses contain a tool_use block, but some contain only a text reply. What explains the text replies?

Included in Master: master every domain.See plans
Question 2easy

A service forces Claude Opus 5 to call an extract_receipt tool whose input_schema defines merchant, date, and total. After the call, where does the service read the extracted fields?

Included in Master: master every domain.See plans