Claude structured output constrains the final agent result to a JSON Schema, while streaming exposes work and partial output as the agent loop progresses. Consume the final structured field only after a successful result; treat deltas as provisional UI events. Validate business rules after schema conformance and design reconnect/cancellation behavior explicitly.
You will configure a triage schema, handle the final result, and choose between single prompt, streaming input, and partial output modes.
Check the current reference for exact result fields in your installed SDK. After receiving the object, validate domain rules such as “billing actions require human review.”
Do not parse JSON incrementally from text deltas when the SDK supplies final structured output.
Test success, schema mismatch, max-turn stop, consumer cancellation, slow consumer/backpressure, and reconnect. Store normalized events with sequence numbers; store final structured outcome separately.
Failure injection: Close the client after it displays 90% of a streamed answer. The run is not automatically complete. Reconnect to persisted events or report that observation detached while the worker followed its cancellation policy.
Build an event adapter with replay from Last-Event-ID, a final-outcome endpoint, and tests for duplicate, missing, and out-of-order delivery.