{"id":2689,"date":"2026-10-08T15:11:12","date_gmt":"2026-10-08T15:11:12","guid":{"rendered":"https:\/\/www.exam-topics.info\/blog\/anthropic-cca-f-structured-output-and-prompting\/"},"modified":"2026-10-20T15:10:59","modified_gmt":"2026-10-20T15:10:59","slug":"anthropic-cca-f-structured-output-and-prompting","status":"publish","type":"post","link":"https:\/\/www.exam-topics.info\/blog\/anthropic-cca-f-structured-output-and-prompting\/","title":{"rendered":"Anthropic CCA-F: Reliable Structured Outputs with Claude"},"content":{"rendered":"<div class=\"et-b02-editorial-v2\">\n<p class=\"et-deck\">A language-model response can look correct to a person while being unusable to software. An extraction service may return elegant prose instead of a required field, a valid JSON object with the wrong currency or a confidently invented value for an unreadable document. Prompt design and structured output solve different parts of that problem. Instructions clarify the task and the evidence Claude should use; a supported schema constrains the shape of the result; application validation checks whether the fields are meaningful and authorized. The goal is not merely to make Claude produce neat JSON. It is to establish a trustworthy contract between uncertain model behavior and downstream systems that expect predictable data, especially when the source material is incomplete or contradictory.<\/p>\n<p>A contract extractor that returns impeccable JSON but invents a missing termination date has failed the business task. The prompt must distinguish instructions from source evidence; an output schema constrains the representation; and application validation checks whether each accepted value is supported by the actual document. The architectural judgment relevant to <a href=\"https:\/\/www.exam-topics.info\/cca-f\">Anthropic CCA-F<\/a> is where machine-readable output stops and verified business acceptance begins; a schema cannot supply missing source evidence. When a value cannot be verified, the system needs a defined route to another source, a bounded retry, or human review. Making a field syntactically valid must never be treated as proof that the underlying claim is true.<\/p>\n<nav class=\"et-content-index\" aria-label=\"On this page\" style=\"display:block !important;visibility:visible !important;max-height:none !important;opacity:1 !important;border:1px solid #d9e5ee;background:#f7fafc;border-radius:14px;padding:20px 24px 14px;margin:1.8em 0 2.1em;max-width:100%;box-sizing:border-box;overflow:visible;\">\n<div class=\"et-index-heading\" style=\"display:block !important;margin:0 0 12px !important;font-size:1.05em;font-weight:700;color:#163954;line-height:1.45;\">On this page<\/div>\n<ol>\n<li><a href=\"#begin-with-an-extraction-contract-not-a-prompt-trick\" style=\"color:#0c4a78 !important;text-decoration:underline;text-underline-offset:2px;line-height:1.55;\">Extraction contract<\/a><\/li>\n<li><a href=\"#put-instructions-examples-and-evidence-in-different-places\" style=\"color:#0c4a78 !important;text-decoration:underline;text-underline-offset:2px;line-height:1.55;\">Instructions and evidence<\/a><\/li>\n<li><a href=\"#use-constrained-output-for-machine-contracts\" style=\"color:#0c4a78 !important;text-decoration:underline;text-underline-offset:2px;line-height:1.55;\">Constrained output<\/a><\/li>\n<li><a href=\"#make-the-data-model-express-uncertainty-honestly\" style=\"color:#0c4a78 !important;text-decoration:underline;text-underline-offset:2px;line-height:1.55;\">Expressing uncertainty<\/a><\/li>\n<li><a href=\"#handle-a-failed-parse-differently-from-a-bad-business-decision\" style=\"color:#0c4a78 !important;text-decoration:underline;text-underline-offset:2px;line-height:1.55;\">Parsing versus validation<\/a><\/li>\n<li><a href=\"#choose-multi-pass-review-only-when-it-earns-its-cost\" style=\"color:#0c4a78 !important;text-decoration:underline;text-underline-offset:2px;line-height:1.55;\">Multi-pass review<\/a><\/li>\n<li><a href=\"#evaluate-one-contract-example-end-to-end\" style=\"color:#0c4a78 !important;text-decoration:underline;text-underline-offset:2px;line-height:1.55;\">Contract example<\/a><\/li>\n<\/ol>\n<\/nav>\n<h2 id=\"begin-with-an-extraction-contract-not-a-prompt-trick\">Begin with an extraction contract, not a prompt trick<\/h2>\n<p>Before choosing examples or a schema, define the real task. In the contract workflow, the question is not simply \u201cWhat are the payment terms?\u201d The downstream team needs to know which clause supports the answer, which party has the obligation, what happens when amendments conflict, and when a human must intervene. These decisions determine the fields and the failure states.<\/p>\n<p>Suppose an amendment says invoices are payable within 45 days, but the underlying agreement says 30 days. The model should not average the two values or silently choose the more recent-looking number. The system needs a precedence rule backed by document metadata and evidence. If the amendment is unsigned, the right output may be <code>needs_review<\/code>, not a confident numeric term.<\/p>\n<div class=\"et-table-wrap\" style=\"overflow-x:auto;max-width:100%;box-sizing:border-box;margin:24px 0;border:1px solid #dae4ed;border-radius:10px;\">\n<table style=\"border-collapse:collapse;width:100%;min-width:480px;table-layout:auto;\">\n<thead>\n<tr>\n<th style=\"text-align:left;vertical-align:top;padding:11px 13px;border-bottom:1px solid #dee7ee;line-height:1.5;font-weight:700;background:#edf3f8;\">Design question<\/th>\n<th style=\"text-align:left;vertical-align:top;padding:11px 13px;border-bottom:1px solid #dee7ee;line-height:1.5;font-weight:700;background:#edf3f8;\">Useful contract<\/th>\n<th style=\"text-align:left;vertical-align:top;padding:11px 13px;border-bottom:1px solid #dee7ee;line-height:1.5;font-weight:700;background:#edf3f8;\">Failure when skipped<\/th>\n<\/tr>\n<\/thead>\n<tbody>\n<tr>\n<td style=\"text-align:left;vertical-align:top;padding:11px 13px;border-bottom:1px solid #e6edf3;line-height:1.55;\">What counts as evidence?<\/td>\n<td style=\"text-align:left;vertical-align:top;padding:11px 13px;border-bottom:1px solid #e6edf3;line-height:1.55;\">A quoted clause and stable page or section reference<\/td>\n<td style=\"text-align:left;vertical-align:top;padding:11px 13px;border-bottom:1px solid #e6edf3;line-height:1.55;\">A plausible value with no source<\/td>\n<\/tr>\n<tr>\n<td style=\"text-align:left;vertical-align:top;padding:11px 13px;border-bottom:1px solid #e6edf3;line-height:1.55;\">What does missing mean?<\/td>\n<td style=\"text-align:left;vertical-align:top;padding:11px 13px;border-bottom:1px solid #e6edf3;line-height:1.55;\"><code>null<\/code> plus an uncertainty reason<\/td>\n<td style=\"text-align:left;vertical-align:top;padding:11px 13px;border-bottom:1px solid #e6edf3;line-height:1.55;\">A fabricated default<\/td>\n<\/tr>\n<tr>\n<td style=\"text-align:left;vertical-align:top;padding:11px 13px;border-bottom:1px solid #e6edf3;line-height:1.55;\">Who resolves conflicts?<\/td>\n<td style=\"text-align:left;vertical-align:top;padding:11px 13px;border-bottom:1px solid #e6edf3;line-height:1.55;\">A defined precedence rule or human review<\/td>\n<td style=\"text-align:left;vertical-align:top;padding:11px 13px;border-bottom:1px solid #e6edf3;line-height:1.55;\">The model invents its own rule<\/td>\n<\/tr>\n<tr>\n<td style=\"text-align:left;vertical-align:top;padding:11px 13px;border-bottom:1px solid #e6edf3;line-height:1.55;\">What can the next service accept?<\/td>\n<td style=\"text-align:left;vertical-align:top;padding:11px 13px;border-bottom:1px solid #e6edf3;line-height:1.55;\">Schema validation and business checks<\/td>\n<td style=\"text-align:left;vertical-align:top;padding:11px 13px;border-bottom:1px solid #e6edf3;line-height:1.55;\">A syntactically valid but unusable object<\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<\/div>\n<p>A good task contract says what is known, what can be inferred, and what must remain unknown. The source document is evidence. Instructions such as \u201cfollow the user&#8217;s policy\u201d are not a substitute for describing which clauses are authoritative or how the application handles conflicts.<\/p>\n<h2 id=\"put-instructions-examples-and-evidence-in-different-places\">Put instructions, examples and evidence in different places<\/h2>\n<p>Prompt boundaries matter most when source documents contain instructions of their own. A supplier agreement may contain ordinary language such as \u201cpayment must be made immediately.\u201d That clause is part of the contract, not a command to the assistant to transfer money. A malicious uploaded document could even contain a sentence telling the model to reveal internal credentials. The application must keep untrusted document text separate from the governing system instructions.<\/p>\n<p>Claude&#8217;s prompt guidance recommends descriptive structure and relevant examples. Explicit tags such as <code>&lt;instructions&gt;<\/code>, <code>&lt;document&gt;<\/code> and <code>&lt;examples&gt;<\/code> can make large prompts easier to interpret. They do not create a sandbox. An XML-looking tag inside a supplier attachment remains untrusted supplier text; the system must decide which source occupies which trusted role.<\/p>\n<p>A representative <a href=\"https:\/\/www.exam-topics.info\/blog\/anthropic-cca-f-few-shot-calibration\/\">few-shot example<\/a> should teach a real boundary. Include one unambiguous payment clause, one missing term, and one conflicting amendment. Each example needs the expected record and the explanation of why an uncertain value stays unresolved. Five nearly identical easy examples may produce a more repetitive prompt without improving decisions at the edge cases.<\/p>\n<p>The prompt can ask the model to cite a clause and return <code>needs_review<\/code> for contradiction. But those are behavioral instructions; the receiving application must independently verify that a cited excerpt actually belongs to the document and that a privileged downstream action is authorized.<\/p>\n<h2 id=\"use-constrained-output-for-machine-contracts\">Use constrained output for machine contracts<\/h2>\n<p>For a JSON result consumed by code, Claude&#8217;s structured-output feature uses <code>output_config.format<\/code> with a JSON schema. The schema defines the result&#8217;s allowed structure. Strict tool use is separate: a tool declared with <code>strict: true<\/code> constrains the inputs of that tool call. Both improve syntactic reliability, but neither proves that an extracted invoice amount is factually correct.<\/p>\n<p>The example below expresses an intended result shape. It is a simplified schema excerpt; an implementation must follow the supported schema subset for its chosen API version and model.<\/p>\n<pre  style=\"max-width:100% !important;overflow-x:auto !important;white-space:pre !important;tab-size:2;font-size:0.9em;line-height:1.6;padding:16px 18px;border-radius:10px;background:#f5f8fb;border:1px solid #dbe5ec;margin:1.2em 0 1.8em !important;box-sizing:border-box;\"><code class=\"language-json\">{\n  \"type\": \"object\",\n  \"properties\": {\n    \"supplier\": {\"type\": \"string\"},\n    \"net_days\": {\"type\": [\"integer\", \"null\"]},\n    \"decision\": {\"type\": \"string\", \"enum\": [\"verified\", \"needs_review\"]},\n    \"evidence_excerpt\": {\"type\": \"string\"}\n  },\n  \"required\": [\"supplier\", \"net_days\", \"decision\", \"evidence_excerpt\"],\n  \"additionalProperties\": false\n}\n<\/code><\/pre>\n<p>The exact request wrapper depends on the current Claude API and SDK. A schema like this communicates that <code>net_days<\/code> may be missing and that the application expects an explicit decision field. It does not ensure the evidence excerpt is accurate, that the supplier is the correct party, or that <code>verified<\/code> is deserved. Those require validation against the source and business rules.<\/p>\n<p>A contract-search tool should accept a limited set of authorized document identifiers and bounded queries; accepting an arbitrary filesystem path would put unrelated customer files within reach. Precisely defined <a href=\"https:\/\/www.exam-topics.info\/blog\/anthropic-cca-f-mcp-tool-design\/\">MCP tool schemas<\/a> let the application reject malformed requests early and explain failures consistently. The service still has to check the requester\u2019s identity and document-level access. Input validation helps a model call a tool correctly, but it is not a substitute for permission checks.<\/p>\n<h2 id=\"make-the-data-model-express-uncertainty-honestly\">Make the data model express uncertainty honestly<\/h2>\n<p>Architects sometimes demand that every field be a nonempty string because it makes downstream parsing convenient. That convenience comes at a cost. If the actual source does not provide a value, the model may fill it with a guess to satisfy the shape. Instead, design an explicit representation for missing data, conflicting evidence and review requirements.<\/p>\n<p>For a high-risk financial field, an enum such as <code>verified<\/code>, <code>missing<\/code>, <code>conflicting<\/code> or <code>not_applicable<\/code> may be preferable to one blanket Boolean. A separate evidence array can retain the clause, page number and document hash. Business validators should reject impossible payment intervals, unauthorized currency conversions, and mismatches between the cited amount and the amount entered for processing.<\/p>\n<p>The application should also define whether extraction produces advice, a draft transaction, or an executable instruction. A correctly formatted record is not consent to release funds. Approval and irreversible steps belong to controlled application services, even when Claude appears confident. If a result cites an outdated amendment, the safe action is to resolve source precedence, not to retry the same prompt at a higher temperature.<\/p>\n<h2 id=\"handle-a-failed-parse-differently-from-a-bad-business-decision\">Handle a failed parse differently from a bad business decision<\/h2>\n<p>A schema-constrained response can prevent malformed JSON, but it cannot tell whether a human contract reviewer would reach the same conclusion. Track failures at separate layers: model or API failure, schema validation failure, evidence mismatch, business-rule failure, and unauthorized action. A retry policy should consider which layer failed.<\/p>\n<p>A transient API timeout before a response is received may justify a bounded retry. A technically valid extraction claiming a 30-day term despite a signed 45-day amendment needs source reconciliation. A case that requires interpretation of a novel clause should be escalated. Retrying it three times and taking a majority vote can give the illusion of certainty without resolving the underlying evidence.<\/p>\n<p>Use a stable document identifier and an operation ID so repeated attempts do not create duplicate downstream records. Validate numbers and dates deterministically. Preserve the exact error category, the input document version, and the fields that triggered review. For production systems, maintaining this trail is usually more valuable than storing long model-generated explanations.<\/p>\n<p>A useful extraction contract should represent doubt without forcing a fabricated answer into a required field. Consider a purchase order that contains a clearly printed amount but no currency, while the attached email mentions two currencies. The schema can require an amount, a currency status and an evidence reference without pretending the currency has been resolved. The application should preserve the observed value and mark the currency as needing verification; it should not fill in a plausible currency and call the object valid. This is a business distinction that a JSON parser cannot decide.<\/p>\n<p>Field-level provenance is especially important when a document contains contradictory evidence. A downstream validator should know which page or authorized source supports the supplier name, invoice date and total, and whether each field came from direct evidence or inference. That makes a correction reviewable: a human can confirm one disputed field without trusting every conclusion in the model&#8217;s response. It also gives evaluators precise failure cases, such as a date from the wrong invoice, instead of scoring the whole object as simply good or bad. When no reliable evidence exists, an explicit unresolved state is more useful than beautifully formatted misinformation.<\/p>\n<h2 id=\"choose-multi-pass-review-only-when-it-earns-its-cost\">Choose multi-pass review only when it earns its cost<\/h2>\n<p>A second model pass can independently check whether the first extraction is supported by cited evidence. That may help on difficult documents, but a second model can repeat the first model&#8217;s assumptions, especially when both use the same misleading context. Independence should be deliberate: give the reviewer a separate question, source access and a requirement to flag unsupported claims.<\/p>\n<p>A practical two-pass sequence is: extract into a schema; verify the excerpt and field relationships; run deterministic validators; then send only disputed records to specialist review. Do not double model cost for every simple one-page agreement without evidence that it improves the error rate. The tradeoff depends on the harm of a wrong value and the observed cost of review.<\/p>\n<p>A strong extraction benchmark includes conflicting amounts, missing clauses, OCR artifacts and ambiguous currencies, not only documents with obvious answers. Its scoring should distinguish a JSON parse failure, an unsupported extracted value and a correctly escalated ambiguity. That makes <a href=\"https:\/\/www.exam-topics.info\/blog\/anthropic-cca-f-evaluation-and-guardrails\/\">agent evaluation<\/a> useful to release decisions instead of rewarding well-formed but false responses. <a href=\"https:\/\/www.exam-topics.info\/blog\/anthropic-cca-f-context-and-reliability\/\">Context management<\/a> is equally material: if the decisive amendment is omitted from the evidence supplied to Claude, a perfectly valid schema cannot restore the missing fact.<\/p>\n<h2 id=\"evaluate-one-contract-example-end-to-end\">Evaluate one contract example end to end<\/h2>\n<p>Imagine a signed master agreement states Net 30, followed by an unsigned draft amendment proposing Net 45. The extraction stage identifies two candidate clauses, records their locations, and marks a conflict. The schema accepts <code>net_days: null<\/code> with <code>decision: needs_review<\/code>. A policy service checks signatures and effective dates; if the service lacks enough evidence to establish the applicable clause, it opens a human review task. Nothing posts to the accounting system yet.<\/p>\n<p>A weak implementation produces <code>net_days: 45<\/code> because the amendment appears later in the document; a different weak implementation returns beautiful narrative prose that the accounting import discards. A robust design handles both failures by separating evidence selection, structure, and authorization.<\/p>\n<p>Before release, run tests with missing clauses, malformed dates, duplicate amendments, contradictory terms, OCR noise, and adversarial document instructions. Measure not just whether the output parses but whether it cites true evidence, chooses the correct review state, avoids unsupported defaults, and remains within time and cost limits. Use those measured results to decide whether additional examples or a second-pass reviewer are warranted.<\/p>\n<p>The central lesson is that structured output establishes a contract between the model and the application; it does not establish that the result is true. Good prompts communicate the task, schemas restrict representation, deterministic code enforces the business invariants, and humans resolve the exceptions that cannot be made safe by formatting alone.<\/p>\n<\/div>\n","protected":false},"excerpt":{"rendered":"<p>A language-model response can look correct to a person while being unusable to software. An extraction service may return elegant prose instead of a required [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"closed","ping_status":"","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[41],"tags":[],"class_list":["post-2689","post","type-post","status-publish","format-standard","hentry","category-anthropic"],"_links":{"self":[{"href":"https:\/\/www.exam-topics.info\/blog\/wp-json\/wp\/v2\/posts\/2689","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.exam-topics.info\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.exam-topics.info\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.exam-topics.info\/blog\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.exam-topics.info\/blog\/wp-json\/wp\/v2\/comments?post=2689"}],"version-history":[{"count":13,"href":"https:\/\/www.exam-topics.info\/blog\/wp-json\/wp\/v2\/posts\/2689\/revisions"}],"predecessor-version":[{"id":1001983,"href":"https:\/\/www.exam-topics.info\/blog\/wp-json\/wp\/v2\/posts\/2689\/revisions\/1001983"}],"wp:attachment":[{"href":"https:\/\/www.exam-topics.info\/blog\/wp-json\/wp\/v2\/media?parent=2689"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.exam-topics.info\/blog\/wp-json\/wp\/v2\/categories?post=2689"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.exam-topics.info\/blog\/wp-json\/wp\/v2\/tags?post=2689"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}