convert_function_to_tool exposes *args and **kwargs as required string parameters

Author: betacatslingCreated Sep 14, 2026Updated Sep 14, 2026

Actual behavior

python
def f(x: int, *args, **kwargs):
    """Do a thing.
    Args:
        x: the number
    """

convert_function_to_tool(f).model_dump()['function']['parameters']
# {'type': 'object', ..., 'required': ['x', 'args', 'kwargs'],
#  'properties': {'x': {'type': 'integer', ...},
#                 'args': {'type': 'string', ...},
#                 'kwargs': {'type': 'string', ...}}}

The generated schema tells the model it must provide args and kwargs string arguments, which is meaningless and can confuse tool calling.

Expected behavior

*args/**kwargs (VAR_POSITIONAL / VAR_KEYWORD) parameters are skipped since they cannot be expressed in the tool JSON schema; only named parameters appear in properties/required.

Environment

  • ollama-python: main @ fa8509936be08809bd15ca90a371165eb9abeb50
  • pydantic 2.10.6, Python 3.11