diff --git a/tests/test_strict_schema_default_refs.py b/tests/test_strict_schema_default_refs.py new file mode 100644 index 0000000000..089899b5f4 --- /dev/null +++ b/tests/test_strict_schema_default_refs.py @@ -0,0 +1,23 @@ +import copy + +from agents.strict_schema import ensure_strict_json_schema + + +def test_default_none_is_removed_from_referenced_property(): + schema = { + "$defs": { + "Value": { + "type": "string", + "default": None, + } + }, + "type": "object", + "properties": { + "value": {"$ref": "#/$defs/Value"}, + }, + } + + result = ensure_strict_json_schema(copy.deepcopy(schema)) + + assert result["$defs"]["Value"] == {"type": "string"} + assert result["properties"]["value"] == {"$ref": "#/$defs/Value"}