Structured Output Prompting

Constrain outputs to schemas (JSON/XML/function calls) to prevent cascading parsing failures.

Structured outputs enforce a parseable format: JSON schemas, function calls, or XML tags.

Why It Matters for Agents

Agents are pipelines: one step’s output becomes the next step’s input. If output is not machine-parseable, errors propagate and amplify.

Key Patterns

  • Define a schema and validate strictly.
  • Return actionable errors when validation fails.
  • Prefer deterministic repair loops over “please try again” prompts.