fix: preserve *args/**kwargs docstring descriptions in tool schemas - #3956
Merged
seratch merged 1 commit intoJul 25, 2026
Merged
Conversation
Google and NumPy style docstrings write variadic parameters with their stars
("*numbers:", "**kwargs:"), and griffe returns those names verbatim.
generate_func_documentation keyed param_descriptions by that verbatim name
while function_schema looks descriptions up by the bare signature parameter
name, so variadic parameter descriptions were silently dropped from the tool
JSON schema for those two styles. Sphinx style has no stars and carried them
through, and function_schema already plumbs the description into the
VAR_POSITIONAL and VAR_KEYWORD fields, so the loss was purely a key mismatch.
Strip the stars when building the description map and cover all three styles
with a parametrized regression test.
seratch
approved these changes
Jul 25, 2026
4 tasks
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.
Summary
Google and NumPy style docstrings write variadic parameters with their stars (
*numbers:,**kwargs:), and griffe returns those names verbatim.generate_func_documentationkeyedparam_descriptionsby that verbatim name, whilefunction_schemalooks descriptions up by the bare signature parameter name — so*args/**kwargsdescriptions were silently dropped from the tool JSON schema for those two styles. Sphinx style (:param numbers:) has no stars and carried them through, andfunction_schemaalready plumbs the description into theVAR_POSITIONAL/VAR_KEYWORDField(...)calls, so the loss was purely a key mismatch. griffe warnings are suppressed during parsing, which made it fully silent.The fix strips the stars when building the description map (
param.name.lstrip("*")). Python identifiers cannot begin with*, so this is a no-op for every non-variadic key.Before, documenting the same function per each style's own convention behaved inconsistently:
After, all three styles carry the descriptions into
params_json_schema.Test plan
test_variadic_param_descriptions_preserved, parametrized over google/numpy/sphinx docstrings for the same(x, *numbers, **kwargs)function, asserting all three descriptions land in the schema properties. The google and numpy cases fail without the fix; sphinx passes before and after, pinning the consistency claim.make format,make lint,make typecheck(mypy + pyright), andmake testsall pass locally.Issue number
None — found while reading
function_schema.py.Checks
.agents/skills/code-change-verification/scripts/run.sh/reviewbefore submitting this PR