-
Notifications
You must be signed in to change notification settings - Fork 3.7k
feat: support self/cls in function_tool for class methods #2734
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Closed
+154
−4
Closed
Changes from 5 commits
Commits
Show all changes
6 commits
Select commit
Hold shift + click to select a range
008294b
feat: skip self/cls parameters in function_tool schema generation
mvanhorn 73b9a9f
fix(schema): reject context param not immediately after self/cls
mvanhorn 2e85520
fix(schema): exclude self/cls from stored signature for to_call_args
mvanhorn 22f1f83
fix: gate self/cls stripping on actual receiver skip
mvanhorn 98ba075
fix: reject unbound methods instead of silently breaking at runtime
mvanhorn f3f480c
fix: skip self/cls instead of rejecting to support decorator pattern
mvanhorn File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
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
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
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.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This branch now throws
UserErrorfor any unannotated first parameter namedself/cls, but@function_toolis applied to unbound functions during class definition, soclass T: @function_tool def f(self, x: str)now fails immediately. Becausefunction_toolalways callsfunction_schema(the_func, ...)on that unbound callable, this change blocks the common decorator workflow for method-based tools instead of allowing them to be registered and later invoked as bound methods.Useful? React with 👍 / 👎.