Skip to content

fix(core): respect positional-only parameters in FunctionTool - #8320

Open
fhgffy wants to merge 1 commit into
microsoft:mainfrom
fhgffy:fix/function-tool-positional-only-20261005
Open

fhgffy wants to merge 1 commit into
microsoft:mainfrom
fhgffy:fix/function-tool-positional-only-20261005

Conversation

@fhgffy

@fhgffy fhgffy commented Oct 5, 2026

Copy link
Copy Markdown

Why are these changes needed?

FunctionTool accepts annotated functions with positional-only parameters and generates their schemas, but calling them fails because every argument is passed as a keyword. For example, def scale(value: int, /, *, factor: int = 2) validates {"value": 3} and then raises TypeError instead of returning 6.

Bind positional-only values in signature order and pass the remaining values as keywords. Cancellation-token injection follows the same binding rules; synchronous executor cancellation keeps its existing behavior.

Eight new regression cases cover sync/async functions, defaults, mixed keyword-only parameters, partial, and positional-only cancellation tokens. All eight fail on the original implementation. The complete core suite passes with the fix: 234 passed. Scoped Ruff, mypy and Pyright checks and the core wheel build also pass. Validation used Windows and Python 3.12.2 with the relevant dependencies aligned to uv.lock; .NET checks were not run.

Related issue number

Fixes #8319

Checks

  • Reviewed documentation impact; argument schemas and public signatures stay the same.
  • Added regression tests corresponding to the change.
  • All GitHub checks have passed (pending CI).

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.

FunctionTool raises TypeError for positional-only parameters after successful schema validation

1 participant