Description
A tool whose parameters use a type that is not a plain JSON type, such as datetime, set or tuple, fails on every invocation with an argument validation error.
FunctionTool._prepare_arguments first runs the arguments through the pydantic input model, which converts the incoming JSON values into Python objects ("2026-01-02T03:04:05" becomes a datetime, a list becomes a set/tuple). The result is then passed to _validate_arguments_against_schema, which compares those Python values against the JSON schema, where the parameter is still declared as string/array. The type check therefore fails on values that pydantic just produced correctly.
Reproduction
import asyncio
from datetime import datetime
from agent_framework import tool
@tool
def when(moment: datetime) -> str:
"""Return the moment as text."""
return moment.isoformat()
@tool
def pick(items: set[str]) -> str:
"""Join items."""
return ",".join(sorted(items))
@tool
def pair(point: tuple[int, int]) -> str:
"""Format a point."""
return f"{point[0]}x{point[1]}"
async def main() -> None:
print(await when.invoke(arguments={"moment": "2026-01-02T03:04:05"}))
print(await pick.invoke(arguments={"items": ["b", "a"]}))
print(await pair.invoke(arguments={"point": [1, 2]}))
asyncio.run(main())
Actual:
Invalid type for 'moment' in 'when': expected string, got datetime
Invalid type for 'items' in 'pick': expected array, got set
Invalid type for 'point' in 'pair': expected array, got tuple
Expected behavior
The tool is invoked with the converted values: when receives a datetime, pick a set[str], pair a tuple[int, int]. These are ordinary annotations that pydantic already handles, and the JSON schema generated for them is correct; only the post-validation type check rejects them.
Environment
- agent-framework-core: main (02bd1ba)
- Python 3.13
Note
python/AGENTS.md says external contributors should check with the core team before picking up issues in the function-calling area, so I have not opened a PR. I am happy to submit one if you can confirm the preferred direction, e.g. validating against the schema before the pydantic conversion rather than after, or skipping the schema type check for parameters whose schema came from a non-JSON-native annotation.
Description
A tool whose parameters use a type that is not a plain JSON type, such as
datetime,setortuple, fails on every invocation with an argument validation error.FunctionTool._prepare_argumentsfirst runs the arguments through the pydantic input model, which converts the incoming JSON values into Python objects ("2026-01-02T03:04:05"becomes adatetime, a list becomes aset/tuple). The result is then passed to_validate_arguments_against_schema, which compares those Python values against the JSON schema, where the parameter is still declared asstring/array. The type check therefore fails on values that pydantic just produced correctly.Reproduction
Actual:
Expected behavior
The tool is invoked with the converted values:
whenreceives adatetime,pickaset[str],pairatuple[int, int]. These are ordinary annotations that pydantic already handles, and the JSON schema generated for them is correct; only the post-validation type check rejects them.Environment
Note
python/AGENTS.mdsays external contributors should check with the core team before picking up issues in the function-calling area, so I have not opened a PR. I am happy to submit one if you can confirm the preferred direction, e.g. validating against the schema before the pydantic conversion rather than after, or skipping the schema type check for parameters whose schema came from a non-JSON-native annotation.