Skip to content

fix(core): preserve variadic Annotated constraints - #4799

Open
Hughhhhcoder wants to merge 1 commit into
openai:mainfrom
Hughhhhcoder:codex/agents-variadic-field-constraints
Open

fix(core): preserve variadic Annotated constraints#4799
Hughhhhcoder wants to merge 1 commit into
openai:mainfrom
Hughhhhcoder:codex/agents-variadic-field-constraints

Conversation

@Hughhhhcoder

@Hughhhhcoder Hughhhhcoder commented Aug 31, 2026

Copy link
Copy Markdown
Contributor

Summary

This pull request fixes function_schema dropping Pydantic Annotated metadata from variadic item types. Constraints on *args items and **kwargs values now remain in the generated JSON schema and runtime validation, while the existing stripped annotation still controls tuple-shape classification.

The implementation reuses Pydantic's nested annotation handling and leaves ordinary parameters, variadic call reconstruction, and strict-schema behavior unchanged.

Test plan

  • .agents/skills/code-change-verification/scripts/run.sh with the repository CI-pinned uv 0.11.14
  • Focused variadic schema tests
  • Targeted mypy check for src/agents/function_schema.py
  • Nested constrained-tuple and constrained-keyword-value probe

The repository wrapper passed format, lint, typecheck, and the full local test suite. Native macOS sandbox-marked tests were skipped locally under the repository's Codex policy and remain covered by the dedicated GitHub macOS job.

Issue number

N/A

Checks

  • I've added new tests, if relevant
  • I've run .agents/skills/code-change-verification/scripts/run.sh
  • I've confirmed all verification steps pass
  • If using Codex, I've run /review before submitting this PR

@Hughhhhcoder

Copy link
Copy Markdown
Contributor Author

@codex review

@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Aug 31, 2026

Copy link
Copy Markdown

Codex Review Summary

This comment shows the latest Codex review activity on this pull request.

Review Status Commit Review trigger
📝 Code Review Completed 2026-08-31T16:44:01.674230Z 68539d4 Draft marked ready
🔒 Security Review Completed 2026-08-31T16:43:08.691144Z 68539d4 Draft marked ready
ℹ️ 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" or "@codex security review".

Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings.

@chatgpt-codex-connector

Copy link
Copy Markdown

Codex Review: Didn't find any major issues. Can't wait for the next one!

Reviewed commit: 68539d4bce

ℹ️ 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".

@chatgpt-codex-connector

Copy link
Copy Markdown

Security review completed. No security issues were found in this pull request.

Reviewed commit: 68539d4bce

View security finding report

Only the user who started this review can view the report in Codex.

ℹ️ About Codex security reviews in GitHub

This is an experimental Codex feature. Security reviews are triggered when:

  • You comment "@codex security review"
  • A regular code review gets triggered (for example, "@codex review" or when a PR is opened), and you’re opted in so security review runs alongside code review

Once complete, Codex will leave suggestions, or a comment if no findings are found.

@Hughhhhcoder
Hughhhhcoder marked this pull request as ready for review August 31, 2026 16:38

@sylvesterkaczmarek sylvesterkaczmarek left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I traced this through the full function_schema() path against the released v0.22.0 compatibility boundary.

The important part is that the change keeps the existing stripped annotation as the source of truth for parameter classification, including the current fixed-length tuple rejection, but uses the include_extras=True annotation only when constructing the collected list[...] / dict[str, ...] value type. That lets Pydantic apply Annotated/Field constraints to each variadic positional item or keyword value without creating a second interpretation of the signature.

I also checked reconstruction: to_call_args() still only extends the validated *args container and updates from the validated **kwargs mapping, so the schema fix does not alter Python call binding or the existing keyword-collision boundary. The new tests exercise both generated JSON-schema constraints and runtime Pydantic rejection, rather than only inspecting annotations.

I don't see a correctness or compatibility blocker in the current head. GitHub's test workflow is still action_required for this fork head, so this is a source/contract verification rather than an independent CI confirmation.

@Hughhhhcoder

Copy link
Copy Markdown
Contributor Author

Thanks for tracing the full function_schema path and checking the compatibility boundary. The current head and regression tests cover the behavior you described, so no additional code change is needed from this review. I will leave the PR open for maintainer review.

@Hughhhhcoder

Copy link
Copy Markdown
Contributor Author

Follow-up validation: with uv 0.12.9, uv run --locked pytest tests/test_function_schema.py -q passes all 54 tests. The worktree remains clean and no source changes were needed for the review.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants