Files
Nicolò Boschi ead16521ea fix(reflect): say when the structured-output extraction failed (#4230)
Reflect with a `response_schema` runs a second LLM call that reshapes the prose
answer into the caller's schema. When that call errored or returned something
unparseable, the bare `except` swallowed it and the caller got 200 with
`structured_output: null` — indistinguishable from an answer that genuinely held
nothing matching the schema. The machine-readable half, which is the reason a
caller supplied a schema at all, failed invisibly: no retry signal, no alert.

Returning 200 with the text answer is still right; the missing piece was saying
the structured half did not happen. `StructuredOutputResult` now carries an
`error`, and reflect surfaces it as a nullable `structured_output_error` on the
response. Present => the extraction broke (retryable); absent with a null
`structured_output` => nothing to extract.

The mental-model refresh path uses the same helper and now records the reason in
its `structured_output_failed` failure detail instead of only "extraction
failed".
2026-09-09 12:38:52 +02:00
..
2025-11-25 19:28:26 +01:00