Skip to content

Support multiple types in tool arguments validation - #1505

Merged
albertvillanova merged 4 commits into
huggingface:mainfrom
duguyue100:support-multiple-types-in-tool-validation
Jul 1, 2025
Merged

albertvillanova merged 4 commits into
huggingface:mainfrom
duguyue100:support-multiple-types-in-tool-validation

Conversation

@duguyue100

@duguyue100 duguyue100 commented Jun 30, 2025 •

Copy link
Copy Markdown
Contributor

Here is the problem: I have an MCP server that is generated from an OpenAPI specification. In one of the input arguments of a tool, it has the type [str, null]. In the argument validation, smolagents only allows a single type for each input argument. This small PR fixes this small issue.

Other docstring changes are from my ruff formatter.

@albertvillanova albertvillanova left a comment •

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks! Good to add support for type as a list.

I added some tests and included a validation of type when it is not a string nor a list of strings.

For the issue with your ruff formatter, next time you need to call make style instead.

@albertvillanova
albertvillanova merged commit 3992f88 into huggingface:main Jul 1, 2025
@duguyue100

Copy link
Copy Markdown
Contributor Author

Thanks for fixing this, much better

maxwellfet928 pushed a commit to maxwellfet928/smolagents that referenced this pull request Jun 8, 2026
Co-authored-by: Albert Villanova del Moral <8515462+albertvillanova@users.noreply.github.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants