fix(tools): name partial-backed tools after wrapped func, use __call__ doc for instances - #7198
Open
aslamalkarywk7 wants to merge 1 commit into
Open
aslamalkarywk7 wants to merge 1 commit into
aslamalkarywk7 wants to merge 1 commit into
Conversation
…_ doc for instances (WIP, awaiting issue approval) Do not open PR before maintainer approval on google#7190.
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.
Fixes #7190
Every functools.partial was advertised (and registered) as 'partial' because partials carry no name, so only the last one survived; and callable instances documented only on call lost their description in the declaration.
This unwraps (nested) partials to the underlying function name, resolves the declaration description through the shared unwrap_callable helper for partials, and falls back to call.doc only for callable instances (partials, types and routines excluded, so an undocumented plain function still yields None and the slot-wrapper Call self as a function. docstring can never leak in).
Verification: new TestPartialAndCallableNaming (6 tests) plus full test_function_tool_declarations.py green (51/51); the existing suite caught one intermediate regression (fallback firing on plain functions) which was fixed before committing.