Skip to content

fix(core): support positional-only arguments in FunctionTool.run() - #8362

Open
MOHAMMED WASIM KHAN (wasim-builds) wants to merge 1 commit into
microsoft:mainfrom
wasim-builds:fix/function-tool-positional-only-args
Open

MOHAMMED WASIM KHAN (wasim-builds) wants to merge 1 commit into
microsoft:mainfrom
wasim-builds:fix/function-tool-positional-only-args

Conversation

@wasim-builds

Copy link
Copy Markdown

Fixes #8319

Summary

In FunctionTool.run(), arguments extracted from the validated args model were previously all passed as keywords via **kwargs. When a tool function defines positional-only parameters (/), Python raises TypeError: <func>() got some positional-only arguments passed as keyword arguments. Similarly, if cancellation_token was declared as a positional-only parameter, passing it as a keyword argument caused a TypeError.

This PR:

  1. Inspects parameter kind in self._signature.parameters.
  2. Gathers positional-only arguments (including positional-only cancellation tokens) into pos_args and remaining parameters into kwargs.
  3. Calls self._func(*pos_args, **kwargs) across both synchronous (via executor/partial) and asynchronous executions.
  4. Adds unit tests covering synchronous and asynchronous functions with positional-only parameters and positional-only cancellation tokens.

Copilot AI balanced review requested due to automatic review settings October 16, 2026 11:00

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copilot was unable to review this pull request because the user who requested the review has reached their quota limit.

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

2 participants