diff --git a/src/agents/strict_schema.py b/src/agents/strict_schema.py index 8ef6701453..3dd934b09a 100644 --- a/src/agents/strict_schema.py +++ b/src/agents/strict_schema.py @@ -79,6 +79,15 @@ def _ensure_strict_json_schema( if is_dict(items): json_schema["items"] = _ensure_strict_json_schema(items, path=(*path, "items"), root=root) + # tuple arrays (Pydantic v2 / JSON Schema draft 2020-12) + # { 'type': 'array', 'prefixItems': [{...}, {...}] } + prefix_items = json_schema.get("prefixItems") + if is_list(prefix_items): + json_schema["prefixItems"] = [ + _ensure_strict_json_schema(entry, path=(*path, "prefixItems", str(i)), root=root) + for i, entry in enumerate(prefix_items) + ] + # unions any_of = json_schema.get("anyOf") if is_list(any_of):