fix(core): preserve Field descriptions on variadic tool parameters - #4951
Closed
subhashpolisetti wants to merge 1 commit into
Closed
subhashpolisetti wants to merge 1 commit into
subhashpolisetti wants to merge 1 commit into
Conversation
A Field() inside Annotated splits into attributes such as description and constraints stored as metadata. Variadic parameters routed the constraints to each collected value but dropped the description, so the advertised tool schema omitted it while the constraints from the same Field() were applied. Fall back to the annotated Field description when no docstring or annotated string supplies one, matching the ordinary-parameter behavior.
Member
|
Thanks for the contribution. The loss of However, the released SDK already supports the same description and constraints through I am going to close this PR for now. We can reconsider if there is a concrete integration that must reuse existing |
1 of 4 tasks
1 of 4 tasks
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
This pull request fixes lost Pydantic
Fielddescriptions on variadic tool parameters.*scores: Annotated[int, Field(description="Exam scores", ge=0, le=100)]advertises the constraints on each collected value but drops the description, so the model is shown an undocumented array argument. The same applies to values collected through**kwargs. Descriptions already reach variadic parameters through docstrings (#3956) and through an annotated string, leavingField(description=...)as the one documented spelling that still loses them.A
Field()insideAnnotatedsplits into attributes such asdescriptionand constraints collected as metadata. #4739 routed the metadata half to each collected value; this carries the description half to the parameter the schema advertises. It applies only when neither a docstring nor an annotated string supplies a description, so the existing precedence is unchanged, and reading only the description keeps the container'sdefault_factoryand the value-level constraint placement #4739 established. Extending the shared_extract_description_from_metadatahelper would be broader than the need: it feeds every parameter kind and would also reorder precedence between aField(description=...)and a sibling string for ordinary parameters.Test plan
test_variadic_field_description_in_schemacovers*argsand**kwargsunder strict and non-strict schemas, asserting the description lands on the parameter while the constraints from the sameField(...)stay on each collected value. Both cases fail onmainwithKeyError: 'description'.make format,make lint,make typecheckanduv run mypy --platform win32 srcare clean..agents/skills/code-change-verification/scripts/run.shdoes not complete in my environment: 14 tests intests/test_code_change_verification_runner.pyfail withTimed out waiting for a controlled process transition. They reproduce identically on unmodifiedmainhere and are unrelated to this change. Excluding that file, the suite reports 9673 passed, 32 skipped.Checks
.agents/skills/code-change-verification/scripts/run.sh/reviewbefore submitting this PR