4.3 — Structured Output with Tool Use

CCAR-F Domain 4 · Task 4.3

What You Need to Know

For guaranteed schema-compliant output: tool_use with JSON schemas (eliminates syntax errors) > prompt-based JSON (no structural guarantees).

tool_choice: Three Modes

Mode Behaviour Use when
"auto" Model decides whether to call a tool Conversational flexibility needed
"any" Must call a tool; chooses which Guaranteed structured output; unknown document type
{"type":"tool","name":"..."} Must call one specific tool Enforce a mandatory first step

What tool_use Does NOT Prevent

  • Sum discrepancies
  • Field placement errors
  • Fabrication of values for required fields when source lacks the data

Semantic validation needs additional logic (Task 4.4).

Schema Design for Production

  • Optional/nullable fields — primary defence against fabrication
  • "unclear" enum value — for genuinely unclear sources
  • "other" + detail string — extensible categorisation
  • Format normalisation rules in the prompt alongside the schema

Key Concept: tool_use with a JSON schema stops syntax errors, not semantic ones. Optional/nullable fields stop fabrication. tool_choice "any" guarantees structured output for unknown document types.

Exam Traps

  • Believing tool_use prevents all extraction errors
  • Relying on tool_choice "auto" to guarantee a tool call
  • Making all schema fields required to ensure completeness

Check your understanding

Practice Scenario

🔒 This practice scenario is part of Skillmarked Pro

The lessons stay free. Pro unlocks the other 23 CCAR-F practice scenarios and the 60-question timed mock exam, plus everything for every other exam.

See plans

Cancel anytime. Or €199 a year, which saves 17%.

Not sure yet? Try 10 free mock exam questions.

Already Pro? Log in.

Sources