Skip to main content

compact_schema

Function compact_schema 

Source
pub fn compact_schema(
    input: &[u8],
    max_examples: usize,
) -> Result<Vec<u8>, SchemaCompactionError>
Expand description

Parses input as JSON, truncates every "examples" array found anywhere in the document (object or array nesting, at any depth) down to at most max_examples elements — keeping the first max_examples elements in their original order — and re-serializes the result in compact form.

Every other key and value in the document (including description, required, enum, type, default, and tool/function name fields) is left exactly as parsed: this function never renames, removes, or reorders anything other than shortening "examples" arrays.

Returns SchemaCompactionError::Invalid if input is not valid JSON.