| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
Sorry, something went wrong.
|
Gentle ping — ready for review, happy to iterate on any feedback. |
Sorry, something went wrong.
|
Re-checked against main today: model_dump_one_level still builds kwargs from field_info.alias, so a tool parameter declared with an explicit Field(alias=...) still raises TypeError: got an unexpected keyword argument. The regression test here fails on main and passes with the change. The change is complete and ready for review. GitHub is refusing to let me flip it out of draft on my end, so if a maintainer can either mark it ready or review it as-is, that unblocks it. maintainerCanModify is on. |
Sorry, something went wrong.
… schema alias a tool parameter with an explicit alias, e.g. city: Annotated[str, Field(alias="location")], is advertised in the input schema as "location" and clients send "location". at call time model_dump_one_level forwarded the value under the alias, so the function was invoked as fn(location=...) and raised TypeError: got an unexpected keyword argument 'location'. track each field's real python parameter name at metadata-build time and forward arguments under it. the internal alias used to dodge BaseModel attribute shadowing (field "field_schema" -> param "schema") is preserved because its real name is recorded the same way. the resolver arg-name matching in tools/base.py reads the same map so by-name resolvers keep resolving.
| Back | FazBrowse Home | New Git URL |
Forward tool arguments to the underlying function under the real parameter name instead of the schema alias.
Motivation and Context
A tool parameter with an explicit alias, e.g. city: Annotated[str, Field(alias="location")], is advertised in the tool input schema as location, and clients send location. At call time model_dump_one_level forwarded the value under the alias, so the function was invoked as fn(location=...) and raised TypeError: got an unexpected keyword argument 'location'. Both sync and async tools are affected.
The root cause is that field_info.alias is used as the kwarg name, but the alias is a wire name, not necessarily a valid Python parameter. It happens to be correct for the internal shadow-rename case (a param named after a BaseModel attribute, e.g. schema -> field field_schema with alias="schema"), where the alias is the real param name — so the two cases are indistinguishable from FieldInfo alone.
The fix records each field's real Python parameter name at metadata-build time and forwards arguments under it. The shadow-rename case keeps working because its real name is recorded the same way. Resolver arg-name matching in tools/base.py reads the same map so by-name resolvers keep resolving.
How Has This Been Tested?
Added a regression test (test_call_with_aliased_parameter) that fails before the change with the TypeError above and passes after. Repro:
Full tests/server/mcpserver/ suite passes locally (552 tests), along with ruff, pyright, and strict-no-cover.
Breaking Changes
None.
Types of changes
Checklist