Structured outputs and bounded tools

Check structured answers before allowing a tool to run.

Visual lessons: 2 · 3:45 total Read estimate: 5 min Practice estimate: 8 hr Updated: 2026-10-03
In this lesson · B6 of 12All lessons in this track →

Progress for this track is saved in this browser only. No completion badge is issued. View your learning.

Start with the idea

Check structured answers before allowing a tool to run.

Validate the output’s fields and values. Then check its evidence and permission separately. Correct formatting does not establish truth or authority.

Schema: A set of rules for the fields, types and values an output may contain.

See the example and check your understanding

A made-up teaching example

The classifier can use two training lookup tools. Requests for an unlisted tool, unknown ID or confidence above one are rejected before execution. A correctly formatted answer also fails if its required source is missing.

Ask yourself

Does valid JSON prove the action is allowed?

Show the explanation

No. Format, source support and permission are separate checks. A generation setting cannot replace them.

Start with these checks

  • Validate fields before execution.
  • Check required source evidence.
  • Enforce tool and ownership limits.

Use the different practice case below and check every requirement in its full instructions.

Go to the practice task ↓

The video explains the main idea. Use the sources, instructions and checks below to complete the practice.

Visual lesson1:40

Captions appear here during playback.

Structured outputs and bounded tools

Check structured answers before allowing a tool to run.

Download transcriptOpen video file

Source-based teaching example · Fictional data · Reviewed 2026-10-03. Microsoft Mark · locally synthesized. On a small screen, use fullscreen for diagram details or read the transcript.

Read the descriptive transcript

0:00 · What you will learn

Check structured answers before allowing a tool to run.

What appears on screen

Check structured answers before allowing a tool to run.

0:06 · The idea

Validate the output’s fields and values. Then check its evidence and permission separately. Correct formatting does not establish truth or authority.

What appears on screen

Validate the output’s fields and values. Then check its evidence and permission separately. Correct formatting does not establish truth or authority.

0:18 · One useful term

Schema. A set of rules for the fields, types and values an output may contain.

What appears on screen

A set of rules for the fields, types and values an output may contain.

0:27 · A worked example

The classifier can use two training lookup tools. Requests for an unlisted tool, unknown ID or confidence above one are rejected before execution. A correctly formatted answer also fails if its required source is missing.

What appears on screen

The classifier can use two training lookup tools. Requests for an unlisted tool, unknown ID or confidence above one are rejected before execution. A correctly formatted answer also fails if its required source is missing.

0:45 · Your turn to think

Does valid JSON prove the action is allowed? Pause and decide before continuing.

What appears on screen

Does valid JSON prove the action is allowed? Pause the video if you need more time.

1:02 · Why this answer works

No. Format, source support and permission are separate checks. A generation setting cannot replace them.

What appears on screen

No. Format, source support and permission are separate checks. A generation setting cannot replace them.

1:12 · Check 1

Validate fields before execution.

What appears on screen

Validate fields before execution.

1:18 · Check 2

Check required source evidence.

What appears on screen

Check required source evidence.

1:23 · Check 3

Enforce tool and ownership limits.

What appears on screen

Enforce tool and ownership limits.

1:28 · Now try a different case

Open the lesson and try its different practice case. Use every check in the full task. Watching alone does not mark the lesson complete.

What appears on screen

Open the lesson Try the new case Check and revise The full task and its requirements are in the linked lesson.

Watching explains the example. Complete the lesson practice to check what you can do. Explore all visual lessons →

What you will be able to do

  1. Validate structured outputs independently of the model.
  2. Implement typed read-only tool interfaces.
  3. Reject unauthorized or malformed tool arguments.

Prerequisites: dictionaries, loops, functions, exceptions and installed Python or paper tracing. Reuse earlier Builder artifacts only when the task requires them.

This curriculum runs self-study on VetsLearn. Where the text calls for an instructor, peer or formal review, use the stated acceptance criteria for self-review. Reflection questions support reflection; they do not replace independent assessment. A peer review is optional unless your actual organization requires it.

Part 1 Technical instruction

A model proposes; application code disposes. JSON or function syntax is not proof that the result is valid. The application validates required fields, types, enumerations, ranges, identifiers, and cross-field rules. Tool exposure begins with a narrow allowlist and read-only behavior. The authorization decision uses the authenticated principal and server-side policy, never a role asserted in prompt text. Validate tool arguments before execution and validate tool results before returning them to the model. Errors should be explicit and should not broaden permissions.

Mechanism and implementation

Schema checks shape, semantic rules check meaning, and authorization checks who may act. Perform all before dispatch. Confidence is not evidence. Exact tools expose bounded operations and IDs, not arbitrary code or shell text. Extra arguments must be rejected rather than forwarded.

Constructed offline example

Save as topic_example.py and run python topic_example.py with an installed Python 3.11+ interpreter. This standard-library construction uses synthetic values; its checks are not provider measurements.

def valid(args):
    if set(args) != {"category", "confidence"}:
        return False
    score = args["confidence"]
    return args["category"] in {"draft", "review"} and type(score) in {int, float} and 0 <= score <= 1
assert valid({"category": "review", "confidence": 0.8})
assert not valid({"category": "review", "confidence": True})
assert not valid({"category": "review", "confidence": 8})
assert not valid({"category": "review", "confidence": 0.8, "role": "admin"})
print("semantic guards passed")

Engineering decisions

  • Define the schema and semantic rules before prompting.
  • Choose the smallest tool surface that completes the task.
  • Fail closed when identity, authorization, or validation is indeterminate.

Worked example

A classifier may return category and confidence and may query two synthetic lookup tools. Attempts to request an unlisted tool, use an unknown identifier, or set confidence above 1.0 are rejected before any execution.

Diagnose the failure

Invalid fields never reach execution. An absent source fails even if output follows JSON Schema. Repair the evidence/ownership lookup; lowering temperature is not a truth control.

Part 2 Guided practice

Explain why bool is rejected despite being an int subclass. Add source IDs and verify claim support. Independently submit a schema-valid claim citing an absent source.

Answer criteria and feedback: Invalid fields never reach execution. An absent source fails even if output follows JSON Schema. Repair the evidence/ownership lookup; lowering temperature is not a truth control.

Continue with the downloadable pack below. If the pack or interpreter is unavailable, trace this self-contained example by hand in an input/expected-status/controlling-rule table and label execution unverified. Do not invent passing output. No account, credential, paid call, purchase or actual deployment is required.

Part 3 Remediation

Reduce the object to one field at a time. Validate structure, then business rules, then authorization. Keep each error distinct so the learner can diagnose the failed boundary. After repair, reassess with the alternate scenario in scenario_alt.json. A critical authorization, data-handling, evidence-integrity, or prohibited-action failure cannot be averaged into successful practice; it requires targeted remediation.

Part 4 Sources and currency

Use the workflow decision reference for model/deployment/harness distinctions and controlled comparisons. Source currency must be checked before each cohort. Provider/product behavior is illustrative where mocked; resolve current interfaces only from official documentation in an authorized environment.

Lesson status:PRACTICE REVIEW REQUIRED

Review your practice