validateOutputSchema

fun validateOutputSchema(output: String, schema: Schema): <Error class: unknown class><Map<String, Any?>>

Parses a model output string as JSON and validates it against a schema.

Mirrors SchemaUtils.validateOutputSchema in the Java ADK and validate_schema in the Python ADK: the output is expected to be a JSON object that matches schema.

Only top-level object schemas are supported: output must parse to a JSON object (it is decoded via Json.fromJsonToMap). Top-level array or primitive schemas are not supported and will yield a Result.failure. This matches the Java ADK; the Python ADK additionally supports list/primitive output schemas.

Return

Result.success wrapping the parsed map if it is valid JSON matching schema; Result.failure if the string is not valid JSON object or does not match the schema.

Parameters

output

The model output string to parse and validate.

schema

The schema to validate against.