Fix transform arg collisions with passthrough params (#3431)

🤖 Generated with GPT-5.2-Codex
This commit is contained in:
Jeremiah Lowin 2026-03-07 11:41:07 -05:00 committed by GitHub
commit d316f193a8
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
2 changed files with 24 additions and 6 deletions

View file

@ -554,12 +554,16 @@ class TransformedTool(Tool):
# Additional validation: check for naming conflicts after transformation
if transform_args:
new_names = []
for old_name, transform in transform_args.items():
if not transform.hide:
if transform.name is not NotSet:
new_names.append(transform.name)
else:
new_names.append(old_name)
for old_name in parent_params:
transform = transform_args.get(old_name, ArgTransform())
if transform.hide:
continue
if transform.name is not NotSet:
new_names.append(transform.name)
else:
new_names.append(old_name)
# Check for duplicate names after transformation
name_counts = {}

View file

@ -482,6 +482,20 @@ def test_transform_args_creates_duplicate_names(add_tool):
)
def test_transform_args_collision_with_passthrough_name(add_tool):
"""Test that renaming to a passthrough parameter name raises ValueError."""
with pytest.raises(
ValueError,
match="Multiple arguments would be mapped to the same names: old_y",
):
Tool.from_tool(
add_tool,
transform_args={
"old_x": ArgTransform(name="old_y"),
},
)
def test_function_without_kwargs_missing_params(add_tool):
"""Test that function missing required transformed parameters raises ValueError."""