Skip to content

fix(tools): preserve an explicitly empty description - #1913

Open
codewithfourtix wants to merge 2 commits into
anthropics:mainfrom
codewithfourtix:fix-explicit-empty-tool-description
Open

fix(tools): preserve an explicitly empty description#1913
codewithfourtix wants to merge 2 commits into
anthropics:mainfrom
codewithfourtix:fix-explicit-empty-tool-description

Conversation

@codewithfourtix

Copy link
Copy Markdown

Passing description="" to beta_tool currently restores the function docstring. Only fall back to the docstring when the argument is None, so callers can explicitly clear a description.

Adds tests for empty, custom, and omitted descriptions.

Signed-off-by: Ali Zulfiqar <codewithfourtix@gmail.com>
@codewithfourtix
codewithfourtix requested a review from a team as a code owner September 5, 2026 17:21
Copilot AI lite review requested due to automatic review settings September 5, 2026 17:21

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🟡 Changes recommended

The new test is not skipped under PYDANTIC_V1, so it will fail in Pydantic v1 environments where beta_tool raises RuntimeError.

Once you've addressed the issues Copilot identified, you can request another Copilot review.

Pull request overview

This PR fixes beta_tool(..., description="") so an explicitly empty description is preserved instead of falling back to the function docstring, only using the docstring when description is None.

Changes:

  • Update tool initialization to treat description="" as an explicit value (fallback only on None).
  • Add a parametrized test covering empty, replacement, and None descriptions for beta_tool.
File summaries
File Description
src/anthropic/lib/tools/_beta_functions.py Adjusts description fallback logic to distinguish None from empty strings.
tests/lib/tools/test_functions.py Adds regression coverage ensuring explicit empty descriptions are preserved.
Review details
  • Files reviewed: 2/2 changed files
  • Comments generated: 1
  • Review effort level: Lite

💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.

Comment thread tests/lib/tools/test_functions.py
Signed-off-by: Ali Zulfiqar <codewithfourtix@gmail.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants