Skip to content

fix(tools): unwrap FieldInfo default to avoid pydantic warning#2955

Open
chaynabors wants to merge 1 commit into
strands-agents:mainfrom
chaynabors:agent-tasks/1914-tool-fieldinfo-default
Open

fix(tools): unwrap FieldInfo default to avoid pydantic warning#2955
chaynabors wants to merge 1 commit into
strands-agents:mainfrom
chaynabors:agent-tasks/1914-tool-fieldinfo-default

Conversation

@chaynabors

Copy link
Copy Markdown
Member

The @tool decorator emitted a PydanticJsonSchemaWarning whenever a parameter used Field(default_factory=...) because _extract_annotated_metadata rebuilt the field with Field(default=param_default, ...), nesting the original FieldInfo as the default value. The fix detects when param_default is already a FieldInfo and rebuilds from its default, default_factory, and validation kwargs so constraints like ge, le, and pattern are preserved.

Fixes #1914.

@github-actions github-actions Bot added size/xs python Pull requests that update python code area-tool Tool behavior/api area-devx Developer experience improvements bug Something isn't working labels Jun 24, 2026
@codecov

codecov Bot commented Jun 24, 2026

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 20.00000% with 4 lines in your changes missing coverage. Please review.

Files with missing lines Patch % Lines
strands-py/src/strands/tools/decorator.py 20.00% 3 Missing and 1 partial ⚠️

📢 Thoughts on this report? Let us know!

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

Labels

area-devx Developer experience improvements area-tool Tool behavior/api bug Something isn't working python Pull requests that update python code size/xs

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[BUG] @tool emits PydanticJsonSchemaWarning for Field(default_factory=list)

1 participant