fix: reject prefixItems in strict tool schemas - #4753
Conversation
|
Automated Codex review identified a compatibility edge case in the current approach: traversing every dict while excluding annotation keys can reject a valid object property literally named The traversal should follow schema-valued positions and treat entries of |
|
Addressed the compatibility edge case from the review comment in commit The strict-schema rejection now traverses only schema-valued JSON Schema positions, including Validation:
The repository-level |
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 54b6e83cbb
ℹ️ About Codex in GitHub
Codex has been enabled to automatically review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
When you sign up for Codex through ChatGPT, Codex can also answer questions or update the PR, like "@codex address that feedback".
| def _reject_prefix_items(schema: object) -> None: | ||
| """Reject ``prefixItems`` in schema-valued positions without inspecting annotations.""" | ||
| stack = [schema] |
There was a problem hiding this comment.
Reuse the existing strict-schema traversal
For the supported case introduced here, Pydantic emits prefixItems beneath properties, and _ensure_strict_json_schema() already visits that node recursively. This standalone walker and its three keyword tables therefore create a second JSON Schema interpreter solely to validate additional direct-helper shapes; the tables can already diverge from the repository's other schema traversal (for example, ToolOutputTrimmer recognizes legacy dependencies, while this walker does not). Keep the prefixItems check inside _ensure_strict_json_schema() and remove the traversal-only tables and tests so strict conversion retains one source of truth.
AGENTS.md reference: AGENTS.md:L94-L96
Useful? React with 👍 / 👎.
There was a problem hiding this comment.
Addressed in commit 359c446b: removed the standalone traversal tables and helper, and kept the prefixItems check inside _ensure_strict_json_schema(), which already follows the schema nodes emitted by Pydantic. The focused regression suite remains green: 130 passed.
Summary
Reject
prefixItemsduring strict JSON schema conversion so ordinary fixed-length tuple parameters fail during tool construction with guidance for supported homogeneous tuples and lists. Non-strict schemas retain their existing behavior.Test plan
uv run --frozen pytest tests/test_function_schema.py tests/test_strict_schema.py tests/test_strict_schema_oneof.py -q(130 passed)uv run --frozen ruff check src/agents/strict_schema.py tests/test_function_schema.py(passed)uv run --frozen ruff format --check src/agents/strict_schema.py tests/test_function_schema.py(passed)uv run --frozen pyright src/agents/strict_schema.py(0 errors)git diff --check(passed)The full pytest suite and single-file mypy check did not complete in the local Windows environment; both remained in dependency/test execution without producing a result and were terminated. No production failure was observed.
Issue number
Closes #4752
Checks
.agents/skills/code-change-verification/scripts/run.sh/reviewbefore submitting this PR