OAI-SE Structured Outputs & Strict JSON Schemas HARD
PRODUCTION SCENARIO
Quarrystone's search backend accepts a proprietary filter language such as region:eu AND (price<40 OR tier:basic), with nested groups, which is plain text rather than JSON. A function tool with a single string parameter produces syntactically invalid filters about one call in twelve.

Which tool design constrains the model's output to the filter language?

Answering here is anonymous. Nothing is saved unless you sign in.

Show answer and explanation

Answer: Define a custom tool with a Lark grammar format describing the whole filter language

Custom tools let the model emit an arbitrary string, and a Lark grammar is context-free, so it can express the balanced nested groups the filter language allows. A regex grammar also constrains the string but cannot match nested parentheses, a schema description is guidance the model can miss, and strict JSON validation checks the object's shape while the filter text inside a string property goes unparsed.
Free

Keep practicing OAI-SE

24 original OAI-SE practice questions, each with an explanation and a source link. No account needed.

Start free practice set → Timed, explained, free