pub fn normalize_for_strict_validators(schema: &mut Map<String, Value>)Expand description
Make a tool input schema acceptable to strict JSON-Schema validators.
OpenAI/Azure (Pydantic-based), Claude thinking models and OpenAI-compatible backends like SGLang reject tool schemas that are valid JSON Schema but omit fields the spec treats as optional. Community-reported failures (OpenCode: “Invalid schema for function ‘lean-ctx_ctx_expand’: None is not of type ‘array’”):
type: "object"withpropertiesbut norequired→ clients forwardrequired: nulland the backend 400s. We always emit an explicit array.type: "array"withoutitems→ “array schema missing items”. We emit a permissiveitems: {}so the wire schema is self-contained.
Runs recursively over every nested schema position (properties, items,
anyOf/oneOf/allOf, object-shaped additionalProperties) so nested
definitions get the same guarantees. Existing required arrays are
preserved verbatim — this never changes which parameters are mandatory.