Skip to content

Conversation

R-Fischer47
Copy link

@R-Fischer47 R-Fischer47 commented Oct 16, 2025

Description

This PR prevents class-based tools from inheriting the docstring of their parent class. When a child tool class does not have its own docstring, it was incorrectly using the parent's, leading to an inaccurate description for the tool.

This holistic fix modifies two files:

  • langchain_core/tools/base.py: The _infer_arg_descriptions function now correctly identifies an inherited docstring and returns None to signal that it should be ignored.
  • langchain_core/tools/structured.py: The StructuredTool.from_function method now correctly handles this None signal. It creates the tool with an empty string "" for its description, while still correctly raising an error for regular functions that are missing a docstring.

This ensures that tools have accurate descriptions and that the developer experience is intuitive.

Issue

Fixes #32066

Dependencies

N/A

@R-Fischer47 R-Fischer47 requested a review from eyurtsev as a code owner October 16, 2025 22:09
@github-actions github-actions bot added core Related to the package `langchain-core` fix labels Oct 16, 2025
@R-Fischer47 R-Fischer47 marked this pull request as draft October 16, 2025 22:11
Copy link

codspeed-hq bot commented Oct 16, 2025

CodSpeed Performance Report

Merging #33540 will not alter performance

Comparing R-Fischer47:R-Fischer47/stop-tool-docstring-inherit (5fe1542) with master (5489df7)1

⚠️ Unknown Walltime execution environment detected

Using the Walltime instrument on standard Hosted Runners will lead to inconsistent data.

For the most accurate results, we recommend using CodSpeed Macro Runners: bare-metal machines fine-tuned for performance measurement consistency.

Summary

✅ 13 untouched
⏩ 21 skipped2

Footnotes

  1. No successful run was found on master (90b6805) during the generation of this report, so 5489df7 was used instead as the comparison base. There might be some changes unrelated to this pull request in this report.

  2. 21 benchmarks were skipped, so the baseline results were used instead. If they were deleted from the codebase, click here and archive them to remove them from the performance reports.

@R-Fischer47 R-Fischer47 changed the title fix(core): prevent inherited docstrings for class-based tools fix(core): prevent inherited docstrings for class-based tools Oct 16, 2025
@github-actions github-actions bot added fix and removed fix labels Oct 16, 2025
@R-Fischer47 R-Fischer47 marked this pull request as ready for review October 16, 2025 22:14
@eyurtsev eyurtsev self-assigned this Oct 17, 2025
@sydney-runkle sydney-runkle self-assigned this Oct 17, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

core Related to the package `langchain-core` fix

Projects

None yet

Development

Successfully merging this pull request may close these issues.

core: docstrings shouldn't inherit from parents

3 participants