Repository navigation
Description
Describe the bug
When a tool function's docstring has no summary line and only an Args: section, all parameter descriptions are dropped. The whole Args: block also ends up in the tool description, flattened. docs/tools.md says "Descriptions for each input are taken from the docstring of the function", and that doesn't happen for this shape.
This is the symptom PR #3795 tried to fix. That PR was closed because the added test should "pass unchanged on the PR's base". I ran that test verbatim against current main and it fails with the locked griffelib==2.0.1. It also fails with 2.3.0. Details are below, with the mechanism, since #3795 didn't explain it.
Debug information
- Agents SDK version:
main@ d3304cf (0.23.1) - Python version: 3.12.3
- griffelib: 2.0.1 (as locked in
uv.lock) and 2.3.0; the result is the same
Repro steps
from agents import function_tool
@function_tool
def get_weather(city: str, unit: str) -> str:
"""
Args:
city: The city to look up.
unit: Either "c" or "f".
"""
return "sunny"
print(repr(get_weather.description))
print(get_weather.params_json_schema["properties"])Actual:
'Args:\ncity: The city to look up.\nunit: Either "c" or "f".'
{'city': {'title': 'City', 'type': 'string'}, 'unit': {'title': 'Unit', 'type': 'string'}}
Expected: description is None, and city / unit carry their descriptions. That is what you get once a summary line ("Get the weather.") is added above Args:.
The test from #3795, copied unchanged into a file and run against main d3304cf with griffelib 2.0.1:
FAILED test_pr3795.py::test_docstring_without_summary_keeps_param_descriptions
assert properties.get("a").get("description") == "the first argument"
where {'title': 'A', 'type': 'integer'} = ...
Root cause
generate_func_documentationtakesinspect.getdoc(func), which cleans the docstring and drops the leading blank line:
'Args:\n city: The city to look up.\n unit: Either "c" or "f".'griffe.Docstring(...)runsinspect.cleandoc()on that value again.cleandoccomputes the common indent from every line except the first. Here that is only the indented parameter lines, so they are dedented to column 0:>>> from griffe import Docstring >>> Docstring("Args:\n city: The city.\n unit: The unit.").value 'Args:\ncity: The city.\nunit: The unit.' >>> [s.kind.value for s in Docstring("Args:\n city: The city.\n unit: The unit.").parse("google")] ['text']
- The Google parser only accepts a section header when indented lines follow it. After step 2 none do, so the block is parsed as free text and becomes the description.
The closing comment on #3795 says cleandoc removes the added leading newline. It does, but only after it has used that newline as line 0. The indent is then computed over all the real lines, so nothing is dedented:
>>> [s.kind.value for s in Docstring("\nArgs:\n city: The city.\n unit: The unit.").parse("google")]
['parameters']The bug doesn't show in the existing tests because they all have a summary line or another column-0 line, such as a Returns: section. Those make the common indent 0. _ensure_blank_line_before_google_sections skips index 0 on purpose, so it doesn't normalize this shape either.
Expected behavior
An Args:-only Google docstring yields the parameter descriptions and no description text. Either of these fixes it:
- Pass
"\n" + doctoDocstring. This is fix: keep parameter descriptions for docstrings without a summary line #3795's change, now with the mechanism above. - Or handle a section header at index 0 in the existing normalizer.
The test in #3795 works as the regression test as written.
Disclosure: found while auditing with AI tooling; reproduced locally on both griffelib versions with the commands above.
Activity
nightcityblade commentedon Oct 5, 2026
Hi, I'd like to work on this. I'll submit a PR shortly.
nightcityblade commentedon Oct 5, 2026
I found the repository's contributor guide limits pull requests to collaborators, so I'm stepping back and leaving this available for maintainers or collaborators.
jnohclee-rgb commentedon Oct 5, 2026
I independently reproduced this through public function_tool on main
d3304cff56f1be2325d00e0f172534d613697f88(SDK 0.23.1, griffelib 2.0.1, Python 3.14.7). Six docstring shapes were checked: Google Args-only and Args-only with wrapped parameter text lost parameter descriptions; Google with a summary, Google with Returns, NumPy Parameters-only, and Sphinx parameter-only retained them. Function bodies were never invoked, tracing was disabled, and no model/API request was made.This isolates the affected layout while preserving alternative parser controls. It does not establish behavior on other griffe/Python versions. The exact offline diagnostic is below.
To run the diagnostic, save it under a
scripts/directory and create a siblingresults/directory. Use the dependency versions above and the pinned SDK source onPYTHONPATH.Diagnostic assistance: prepared with Codex and independently executed against the pinned source; all inputs are fictional.