From a163c3ce4a5629bd792ffbdcc8d7dd5a804b3555 Mon Sep 17 00:00:00 2001 From: Dev-X25874 <283057883+Dev-X25874@users.noreply.github.com> Date: Wed, 20 May 2026 13:36:45 +0530 Subject: [PATCH] strict_schema: recurse into prefixItems entries for tuple schemas --- src/agents/strict_schema.py | 9 +++++++++ 1 file changed, 9 insertions(+) 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):