# Schema-Free Output

> Parsing free-form model text with regex in downstream code — and getting silent data corruption when the model phrases things differently.

- **Category**: Agentic AI
- **Subcategory**: Anti-Patterns
- **Canonical URL**: https://designpattern.fyi/patterns/schema_free_output/

---

## Description
**Intent**: Asking the model for free-form text and consuming it with string parsing, regex, or substring checks in downstream code.

**Context**: The model is asked to return a JSON-looking blob, a yes/no, or a list. The provider offers structured output — JSON Schema, Pydantic, function calling. The team skips it ("seemed like extra setup"). Now downstream code does `if ''yes'' in response.lower()` and ships. One model update later, the phrasing shifts and the parser silently breaks.

**Solution**: Use structured output from the start: JSON Schema, Pydantic, or function calling. If your provider doesn''t support it, validate with strict post-parse and retry on failure. See structured-output, tool-use.



## Use Cases
- Never use this; downstream code parsing free-form model text is brittle and silently corrupts state.
- Use structured-output (JSON Schema, Pydantic, function calling) instead.
- If the provider lacks structured output, validate with strict post-parse and retry.






## Trade-offs




### Considerations & Drawbacks

- Parser breaks whenever model phrasing shifts — one model update away from failure

- State corruption is silent — no exception thrown, just wrong data propagated downstream

- Debugging incorrectly blames the model when the parser is at fault







---
**Reference**: [Original Source](https://www.agentpatternscatalog.org/patterns/schema-free-output/)

