Parsing comes after the response-state decision. An incomplete answer can contain a plausible fragment of JSON, and a refusal can coexist with message metadata. Keep those outcomes distinct so a caller can retry, ask for help or stop without treating missing data as a successful answer.
Create the scripted reply and call model_dump(). Return status incomplete before parsing when status is not completed. Return status refused if any message content item is a refusal. Otherwise parse output_text as JSON and return status ready with the parsed value. Malformed JSON returns status invalid.
The notebook executes your Python against an original local mock. Use the supplied case rather than copying visible values. The hidden checks change identities, revisions and boundary inputs; no provider endpoint or external tool is contacted.
An example implementation of the function contract.