Structured outputs and validation

Home Learn Structured outputs and validation

In short

A structured output puts an answer into defined fields that software or a person can inspect. A schema describes the allowed shape and types of those fields. An answer can match the schema and still contain incorrect values, so format checks and factual checks have different jobs.

Why it matters

A paragraph is useful for reading, but a workflow may need a date, a category, and a source location in separate fields. A missing value or an unexpected label can interrupt that workflow. Worse, a guessed value can move through it without drawing attention. Defining the output clearly gives both the software and the reviewer something specific to check.

How it works

Format is a useful constraint

JSON, or JavaScript Object Notation, is a text format for exchanging data. It can represent named fields, lists, text, numbers, true-or-false values, and null. Null is an explicit value that applications can use to represent absence, according to their agreed rules. The JSON standard defines the format; it doesn’t establish whether the contents are true.

A schema specifies requirements such as field names, data types, required fields, and allowed values. JSON Schema defines a vocabulary for these checks. For example, a category could allow only “question,” “request,” or “other.” A validator is software that checks whether an output follows the schema.

An assistant can be asked to follow a format. Some applications also constrain generation through software. Those are different levels of enforcement. Even a constrained output needs checks on what each field means and whether it matches the source.

Define how absence works

Decide what should happen when a source omits a field. Allow an explicit unknown value where appropriate. Don’t require a date and then silently accept a date the source never supplied.

Preserve evidence locations so a reviewer can find the original passage. Check relationships between fields as well as individual types. A correctly formatted end date can still precede the start date. Application-specific rules handle that kind of meaning.

Separate extraction from a decision

Extraction proposes values from a source. A later decision uses those values for a purpose. I’d keep uncertain extraction out of a consequential action until it’s resolved. A tidy record is a good place to begin review, not a reason to skip it.

Example

Illustrative example: this scenario is invented.

Eli works in IT support and security. They use a ticket note: “The shared printer stopped responding after a restart. Please contact the requester; no urgency level was provided.”

An extraction task can return the affected equipment, reported symptom, and an unknown urgency. It should preserve the note as evidence. A record containing a guessed emergency category could have the right shape while changing the meaning of the request. Eli checks that the output separates what was stated from what still needs a question.

What it doesn’t mean

  • Valid JSON doesn’t mean valid facts. A parser checks syntax.
  • A schema isn’t a complete business rule. Some relationships need additional checks.
  • A required field shouldn’t force a guess. Define how incomplete evidence is handled.

Try it

Use about ten minutes to write a sample event note with a title, location, and missing registration deadline. Ask an assistant to return those fields, plus an evidence phrase for each. Require null for a missing value.

Check the output by hand: field names, types, supported values, and how it represents the deadline. Then add the deadline and request a revision. Keep the facts unchanged while changing the structure.

Keep going

Sources

Share this page