Skip to content

Respect default arguments in function tool schemas - #763

Open
shayanxcyber wants to merge 3 commits into
ollama:mainfrom
shayanxcyber:fix/function-tool-defaults
Open

shayanxcyber wants to merge 3 commits into
ollama:mainfrom
shayanxcyber:fix/function-tool-defaults

Conversation

@shayanxcyber

@shayanxcyber shayanxcyber commented Oct 14, 2026 •

Copy link
Copy Markdown

For def search(query: str, limit: int = 5), the tool schema currently marks limit as required. Use the callable signature to keep defaulted arguments optional, including keyword-only and nullable arguments.

The schema needs to know which arguments can be omitted. Python supplies the actual defaults when the function is called. A default factory keeps values such as object() out of JSON serialization and keeps ... from being mistaken for a required field.

The utility tests and type doctests pass with warnings treated as errors (20 passed). Ruff lint and formatting pass.

This branch has not been deployed

No deployments
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.

1 participant