convert_function_to_tool exposes *args and **kwargs as required string parameters
Nobody has claimed this yet.
- Dominant language
- Python
- Stars
- 10.5k
- Forks
- 1.2k
- Avg merge
- 4m
- Merged PRs (30d)
- 1
Description
Actual behavior
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
Contributor guide
No contributing guide indexed for this repository
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start at the convert_function_to_tool entry point and inspect how VAR_POSITIONAL and VAR_KEYWORD parameters are turned into the generated schema. Reproduce the issue with the function shown, then verify that only named parameters appear in properties and required, while args and kwargs are omitted.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- python
- Domain
- backend-api-design
- Issue type
- Bug
- Difficulty
- 2/5
- Estimated time
- 1-3 hours
- Activity status
- Active
- Clarity
- Clearly specified
- Newbie friendliness
- 88/100