Overview
When a request does not behave as expected, Instructor provides several inspection points at different levels of detail. Start with the smallest useful tool and escalate as needed.Quick Inspection Points
Response Envelope
Theresponse() method returns a StructuredOutputResponse that pairs the parsed
value with the raw provider response:
Raw Provider Response
If you only need the raw inference response without deserialization metadata:Execution Metadata
Access the execution object from aPendingStructuredOutput to inspect the request
configuration, attempt history, and output mode:
Streaming Responses
When streaming, useresponses() to inspect each emitted StructuredOutputResponse:
Runtime Events
For deeper tracing, attach a wiretap to the runtime. This gives you visibility into every internal stage — schema building, inference calls, extraction, deserialization, validation, and transformation:JSON Output Inspection
When you need to see the raw JSON that came back from the provider (before deserialization), use thetoJson() or toArray() methods on PendingStructuredOutput:
Common Debugging Scenarios
Wrong or Missing Fields
Check that your response model class has the correct property types and names. Usewiretap() to inspect the raw JSON from the provider and compare it with your
schema expectations.
Validation Failures Exhausting Retries
Listen forResponseValidationFailed events to see exactly which validation rules
are failing. Consider increasing maxRetries or relaxing validation constraints.
Unexpected Deserialization Errors
Listen forResponseDeserializationFailed to see the raw data that could not be
mapped to your class. This often reveals type mismatches between the schema and
the actual model response.
Streaming Not Producing Updates
Verify thatwithStreaming(true) is set and that you are consuming the stream
(e.g., iterating partials() or calling finalValue()). The stream is lazy —
no data flows until you start reading.