Repository navigation
fix(autogen-core): pass positional-only tool arguments positionally - #8415
Open
Phani Paladugula (phanipaladugula) wants to merge 1 commit into
Open
Phani Paladugula (phanipaladugula) wants to merge 1 commit into
Phani Paladugula (phanipaladugula) wants to merge 1 commit into
Conversation
FunctionTool generated a valid schema for annotated functions with positional-only parameters, but run() always called the wrapped function with keyword arguments, so every call raised TypeError after validation. Collect positional-only parameters and pass them positionally in signature order, keeping the rest as keywords. This also covers an injected cancellation_token declared as positional-only, and preserves the existing cancellation behaviour for sync functions. Closes microsoft#8319
Author
|
@microsoft-github-policy-service agree |
Author
|
Hi Eric Zhu (@ekzhu) — this is ready for review whenever you have a moment. It fixes #8319 by splitting positional-only arguments out before building kwargs, with five regression tests. |
This branch has not been deployed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Why are these changes needed?
FunctionToolbuilds a valid argument schema for an annotated function with positional-only parameters, butrun()passed every argument by keyword. Validation therefore succeeded and the call then failed withTypeError:This affects sync and async functions, and an injected
cancellation_tokendeclared as positional-only.run()now collects positional-only parameters and passes them positionally, in signature order, keeping all other parameters as keywords. Sync functions still link the future only when the wrapped function does not take the cancellation token, as before.Related issue number
Closes #8319
Checks
Verification
Tests added to
python/packages/autogen-core/tests/test_tools.py:cancellation_token;Each case fails on the unchanged implementation for the reported reason and passes with the change.
(The two ignored files need
autogen-ext, which is not part of this package's test environment.)