Skip to content

docs: describe Pydantic Field annotations for tool args#2436

Open
haasonsaas wants to merge 1 commit intoopenai:mainfrom
haasonsaas:codex/2428-docs
Open

docs: describe Pydantic Field annotations for tool args#2436
haasonsaas wants to merge 1 commit intoopenai:mainfrom
haasonsaas:codex/2428-docs

Conversation

@haasonsaas
Copy link

Docs follow-up for #2428 / #2435.

Keeps documentation changes separate so runtime changes can merge independently from doc/release cadence.

Document both default-based and Annotated forms for constraining
and describing function-tool arguments (addresses review request
in PR openai#1124).
@github-actions github-actions bot added the documentation Improvements or additions to documentation label Feb 7, 2026
Copy link

@chatgpt-codex-connector chatgpt-codex-connector bot left a comment

Choose a reason for hiding this comment

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

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: d36b46f6a5

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

Comment on lines +295 to +298
# Annotated form
@function_tool
def score_b(score: Annotated[int, Field(..., ge=0, le=100, description="Score from 0 to 100")]) -> str:
return f"Score recorded: {score}"

Choose a reason for hiding this comment

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

P2 Badge Remove claim that Annotated Field constraints are applied

The docs state that the Annotated form (Annotated[int, Field(..., ge=1)]) is supported and that constraints are included in the generated schema, but function_schema currently strips Annotated metadata via _strip_annotated() and only keeps string metadata for descriptions. This means Field(...) inside Annotated is discarded, so constraints like ge/le are not applied to tool args. Unless the runtime is updated to preserve Field metadata from Annotated, this example is misleading and can cause users to believe constraints will be enforced when they will not.

Useful? React with 👍 / 👎.

@haasonsaas
Copy link
Author

Docs PR is green and pairs nicely with #2435. Ready to merge when a maintainer can.

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

Labels

documentation Improvements or additions to documentation

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants