fix(core): preserve fixed tuple annotations for variadic tool arguments - #4696
fix(core): preserve fixed tuple annotations for variadic tool arguments#4696rioyu123 wants to merge 2 commits into
Conversation
|
@codex review |
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: ecd123b581
ℹ️ About Codex in GitHub
Your team has set up Codex to 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 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
|
Security review completed. No security issues were found in this pull request. Reviewed commit: Only the user who started this review can view the report in Codex. ℹ️ About Codex security reviews in GitHubThis is an experimental Codex feature. Security reviews are triggered when:
Once complete, Codex will leave suggestions, or a comment if no findings are found. |
ecd123b to
2771088
Compare
|
@codex review |
|
Security review completed. No security issues were found in this pull request. Reviewed commit: Only the user who started this review can view the report in Codex. ℹ️ About Codex security reviews in GitHubThis is an experimental Codex feature. Security reviews are triggered when:
Once complete, Codex will leave suggestions, or a comment if no findings are found. |
|
@codex review |
|
Security review completed. No security issues were found in this pull request. Reviewed commit: Only the user who started this review can view the report in Codex. ℹ️ About Codex security reviews in GitHubThis is an experimental Codex feature. Security reviews are triggered when:
Once complete, Codex will leave suggestions, or a comment if no findings are found. |
seratch
left a comment
There was a problem hiding this comment.
The Python annotation analysis is correct, but the proposed provider schema relies on prefixItems. OpenAI Structured Outputs supports only a documented JSON Schema subset, and prefixItems is not listed among the supported array properties. Unsupported strict schemas are rejected by the API.
Because function tools normally use strict schemas, we should not make fixed-length variadic tuples generate prefixItems without authoritative evidence that this is accepted across the supported OpenAI tool paths and models.
Please narrow this to an actionable construction-time error for fixed-length tuple annotations, while preserving the existing homogeneous tuple[T, ...] behavior. That keeps the unreleased #4655 correction without adding a provider contract we cannot currently substantiate.
|
Checked this PR again. I am closing this because emitting The narrower SDK behavior should be to reject fixed-length tuple annotations during tool construction and identify |
Summary
This pull request fixes schema generation for fixed-length tuple annotations used on variadic tool parameters.
A signature such as
*args: tuple[int, str]currently degrades tolist[Any], so the generated JSON Schema accepts invalid arity and element types. This change preserves any parameterized tuple as the type of each positional argument while retaining the existing permissive behavior for bare and empty tuple annotations, including the Python 3.10typing.Tuple[()]representation.Fixed tuples are represented with
prefixItems. Strict schema conversion now traverses those entries, closing nested object schemas and rejecting free-form mappings during tool construction instead of sending a non-strict schema to the provider.Regression coverage verifies schema constraints, nested strictness, invalid open mappings, validation failures, and reconstruction of validated positional arguments into tuples.
Test plan
uv run pytest -q tests/test_function_schema.py tests/test_strict_schema.py(113 passed)Issue number
N/A
Checks
.agents/skills/code-change-verification/scripts/run.sh