# Record
**Author:** @cameron.stream (`did:plc:gfrmhdmjvxn2sjedzboeudef`)

## `knowledge-structured-outputs`
**Collection:** `site.standard.document`
**AT URI:** `at://did:plc:gfrmhdmjvxn2sjedzboeudef/site.standard.document/knowledge-structured-outputs`

**Title:** Structured Outputs
**Published:** Mon, 20 Jul 2026 23:00:00 GMT
**Updated:** Mon, 20 Jul 2026 22:40:00 GMT
**Description:** Constraining language-model generation so downstream systems receive valid, schema-shaped data.
**Publication:** `at://did:plc:gfrmhdmjvxn2sjedzboeudef/site.standard.publication/3mr4py6clps2f`
**Path:** /structured-outputs
**Tags:** knowledge, concept, ai, structured-generation, constrained-decoding, software

**Content:**
```json
{
  "text": "Structured outputs are language-model responses constrained to match a machine-readable schema or grammar. They allow downstream software to receive predictable fields and types rather than treating free-form prose as an informal data interface.\n\n## Constrained decoding\n\nOne implementation strategy is **constrained decoding**. At each generation step, the decoder limits token choices to continuations that can still produce a valid output under a JSON schema, grammar, regular expression, or parser. Invalid strings become unreachable rather than merely discouraged by a prompt.\n\nTokenization makes this more subtle than filtering one character at a time. A token can contain several characters or cross a grammar boundary. Implementations commonly compile the accepted language into a state machine and map each parser state to the tokens that remain valid.\n\n## Validation and semantics\n\nPost-generation validation detects malformed output after the model has spent the request producing it. Retries can repair some failures but add latency and still offer no guarantee of success. Constrained decoding moves shape validation into generation and can guarantee syntactic validity for supported schemas.\n\nSyntactic validity does not guarantee semantic truth. A schema can require a field named `price` to contain a number without proving that the number is current, correctly sourced, or denominated in the intended currency. Applications still need domain validation, authorization checks, and evidence for consequential claims.\n\n## Uses and limits\n\nStructured outputs are useful for tool calls, extraction, classification, workflow state, configuration, and agent-to-agent protocols. They are especially important when generated data will cause an external effect rather than merely be displayed to a reader.\n\nConstraint systems vary in expressive power and cost. Finite-state constraints are efficient for many regular languages. Recursive grammars and cross-field conditions may need stronger parsers or a second validation phase. Highly restrictive schemas can also change the model's probability distribution and reduce answer quality if the allowed structure does not fit the task.\n\nIn [spec-driven development](https://cameron.stream/knowledge/spec-driven-development-for-ai-coding-agents), a structured response format can make task plans and completion receipts machine-checkable. It does not replace the specification that defines what those fields mean.\n\n## Sources\n\n- [Outlines](https://github.com/dottxt-ai/outlines)\n- [JSON Schema](https://json-schema.org/specification)\n- [OpenAI Structured Outputs](https://openai.com/index/introducing-structured-outputs-in-the-api/)",
  "$type": "site.standard.content.markdown",
  "version": "1.0"
}
```

---
*Fetched from https://enoki.us-east.host.bsky.network via `com.atproto.repo.getRecord`*