ollama / ollama/ollama-python

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

Open Beginner friendly
#735 0 comments 0 reactions 0 assignees View on GitHub

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

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. 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

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.