openai.internal._prune_nulls

(internal) Drop every null-valued map entry, recursively. The typed request classes declare optional fields for everything the provider treats as absent, and `to_json` renders an unset optional as an explicit null — which is not the same request. This runs on the serialized typed request only, BEFORE the user's `request_body` merge (where a null legitimately means "delete").

Reference version

Signature

function openai.internal._prune_nulls(value: baml.json.json) -> baml.json.json

(internal) Drop every null-valued map entry, recursively. The typed request classes declare optional fields for everything the provider treats as absent, and to_json renders an unset optional as an explicit null — which is not the same request. This runs on the serialized typed request only, BEFORE the user's request_body merge (where a null legitimately means "delete").

It is a TYPED-LAYER pass and must never be the last word on an open-ended subtree: a tool's parameters is the caller's own JSON Schema, where "default": null / "const": null are legitimate members rather than unset optionals. Those subtrees are written back verbatim afterwards by _restore_tool_schemas; request_body is merged after the prune and never sees it at all.

Source:<builtin>/openai/ns_internal/responses.bamlbytes 64087200