fix(schema): decode URI fragments before JSON Pointer traversal

Author: Afloat16Created Sep 30, 2026Updated Sep 30, 2026

Reproduction

Baseline: 3590e5d949638b86fb402cdde42460e6ccbc4933 in openai/openai-agents-python.

resolve_ref() splits the URI fragment and applies ~1/~0 escapes without first decoding percent-encoded UTF-8. A valid reference can raise KeyError, or silently resolve to a different existing schema when encoded and literal-percent names coexist.

With $defs["A B"]={"type":"string"} and $defs["A%20B"]={"type":"integer"}, #/$defs/A%20B resolves to integer before the patch and to string after it.

Expected behavior

Decode the local URI fragment once with urllib.parse.unquote(..., errors="strict"), then split its JSON Pointer path and retain the existing ~1-before-~0 order and nested-resource guard. Do not use unquote_plus. Add regression tests for Unicode, percent signs, structural separators, plus signs and name collisions.

Evidence and proposed scope

24 focused checks; 14 fail before the patch. The collision case proves wrong-target selection, not merely an exception.

Focused execution uses the exact resolve_ref and _declares_schema_resource bodies with explicit is_dict/UserError imports supplied at the boundary. It does not exercise the complete strict-schema conversion pipeline, an installed Agents SDK or an OpenAI API request. This does not add array-index or root-# support and does not claim complete RFC 6901 implementation.

A narrowly scoped patch and regression tests are prepared. No model-quality, full-project CI, or GPU throughput claim is made.

Reporting through an issue in accordance with the current collaborator-only PR policy. The affected source blob remains unchanged at current main c513dd181441baffa841151d84cf8bbac38556cf.

Source: openai/openai-agents-python