Repository navigation
Python: Fix tool names and descriptions for partials and callable instances - #10135
Closed
Trainingcqy wants to merge 2 commits into
Closed
Trainingcqy wants to merge 2 commits into
Trainingcqy wants to merge 2 commits into
Conversation
Trainingcqy
temporarily deployed
to
github-app-auth
November 6, 2026 08:53 — with
GitHub Actions
Inactive
Trainingcqy
had a problem deploying
to
github-app-auth
November 6, 2026 08:53 — with
GitHub Actions
Error
Author
|
@microsoft-github-policy-service agree |
Trainingcqy
temporarily deployed
to
github-app-auth
November 9, 2026 09:29 — with
GitHub Actions
Inactive
Member
|
Trainingcqy, thank you for the contribution. The maintainer direction on #10134 explicitly says not to add core automatic name or description inference for partials and callable instances; callers should supply |
This branch was previously 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.
Motivation & Context
functools.partialobjects and class instances with__call__have no__name__, sotool()gives them all the default nameunknown_function. When two such tools are passed to the same Agent,agent.run()raises aValueErrorfor the duplicate name. A partial's default description is the docstring of thefunctools.partialclass itself. Reproduction: #10134.Description & Review Guide
_get_callable_nameand_get_callable_description, which unwrap each layer of partial lacking its own__name__and its own__doc__, respectively. A callable instance without__name__gets its class name, as_middleware.pydoes when naming middleware. When the class has no docstring and its__call__is a Python function, the__call__docstring is used. Updates thetool()docstring to match and adds the parametrized testtest_tool_default_name_and_description.titlechanges with the name to<name>_input. Plain functions, methods, and classes are unaffected. When a plain function and its own partial, or a class and its instance, are passed together,agent.run()will raise aValueErrorfor the duplicate name, and they needname=to tell them apart;MontyCodeActProviderdeduplicates by name and keeps only the one passed last. Function calls namedunknown_functionin sessions saved before the upgrade no longer match any tool.__call__docstring is used only for instances. The__call__of functions and partials is built in and carries only the generic text "Call self as a function." The__call__of a class object comes from its metaclass, and without this exclusion anEnumsubclass would get the docstring ofEnumType.__call__.Related Issue
Fixes #10134
AI Assistance
AI assistance details: Completed with assistance from Claude Code and verified by me.
Contribution Checklist
breaking changelabel (or add "[BREAKING]" to the title prefix, before or after any language prefix) — a workflow keeps the label and title prefix in sync automatically.