Checks
Strands Version
1.30.0
Python Version
3.11.x
Operating System
macOS 15.7
Installation Method
pip
Steps to Reproduce
from pydantic import Field
from strands import Agent, tool
@tool
def example(
items: list[str] = Field(default_factory=list, description="items"),
) -> int:
"""Example tool."""
return len(items)
Agent(tools=[example])
# PydanticJsonSchemaWarning: Default value annotation=NoneType required=False default_factory=list description='items' is not JSON serializable; excluding default from JSON schema [non-serializable-default]
Expected Behavior
No warning should be emitted. default_factory=list should be handled correctly when Strands builds the tool input schema.
Actual Behavior
Strands emits a Pydantic warning while generating the tool schema:
PydanticJsonSchemaWarning: Default value ... default_factory=list ... is not JSON serializable; excluding default from JSON schema
This looks like the decorator rebuilds the field as Field(default=<FieldInfo>), so Pydantic sees a non-serializable default.
Additional Context
I could not find an issue for this exact warning, but it looks related to the custom tool-validation/schema path discussed in #1246 and #917. It also seems similar in spirit to #337, but this case is about function-tool parameters using Field(default_factory=...).
Possible Solution
If a parameter default is already a Pydantic FieldInfo, preserve it instead of wrapping it again in Field(default=param_default, ...).
Related Issues
No response
Checks
Strands Version
1.30.0
Python Version
3.11.x
Operating System
macOS 15.7
Installation Method
pip
Steps to Reproduce
Expected Behavior
No warning should be emitted.
default_factory=listshould be handled correctly when Strands builds the tool input schema.Actual Behavior
Strands emits a Pydantic warning while generating the tool schema:
This looks like the decorator rebuilds the field as
Field(default=<FieldInfo>), so Pydantic sees a non-serializable default.Additional Context
I could not find an issue for this exact warning, but it looks related to the custom tool-validation/schema path discussed in #1246 and #917. It also seems similar in spirit to #337, but this case is about function-tool parameters using
Field(default_factory=...).Possible Solution
If a parameter default is already a Pydantic
FieldInfo, preserve it instead of wrapping it again inField(default=param_default, ...).Related Issues
No response