Repository navigation
Conversation
This change improves the robustness of the BaseTool class by ensuring that tool names are compatible with LLM function-calling requirements. Key Changes: - Added explicit `str` type hints to `name` and `description` in the `BaseTool.__init__` method. - Implemented a validation check that raises a `ValueError` if a tool name contains spaces. Reasoning: Most LLMs (including Gemini) expect function names to follow standard identifier rules (no spaces). Providing a tool with a space in the name can cause silent failures or unexpected behavior during the "Reason-Act" loop. This fix catches the error at instantiation time, providing a clear guidance to the developer to use underscores instead. Test Coverage: - Verified that `BaseTool(name="valid_name", ...)` passes. - Verified that `BaseTool(name="invalid name", ...)` raises ValueError.
|
Response from ADK Triaging Agent Hello @Pranav334, thank you for your contribution! To help us with the review process, could you please associate an issue with this PR? If one doesn't exist, please create a new issue that this PR will address. Also, it looks like the You can find more details in our contribution guidelines. Thanks! |
| is_long_running: bool = False, | ||
| custom_metadata: Optional[dict[str, Any]] = None, | ||
| ): | ||
| # -CONTRIBUTION START --- |
There was a problem hiding this comment.
Pls remove these comments
| custom_metadata: Optional[dict[str, Any]] = None, | ||
| ): | ||
| # -CONTRIBUTION START --- | ||
| if " " in name: |
There was a problem hiding this comment.
add a regex to include all prohibited naming conventions.
There was a problem hiding this comment.
Ok Rohit I will look into it Thanks
|
Hi @Pranav334 , Thank you for your contribution! We appreciate you taking the time to submit this pull request. |
|
Hi @rohityan |
|
Enforcing strict no-whitespace validation in BaseTool.init is a breaking change that breaks existing tools and third-party wrappers across the ecosystem. Function naming constraints should be sanitized or validated when converting tools to specific LLM schema declarations (e.g. Gemini FunctionDeclaration) rather than breaking base tool instantiation. Closing this PR. |
This change improves the robustness of the BaseTool class by ensuring that tool names are compatible with LLM function-calling requirements.
Key Changes:
strtype hints tonameanddescriptionin theBaseTool.__init__method.ValueErrorif a tool name contains spaces.Reasoning:
Most LLMs (including Gemini) expect function names to follow standard identifier rules (no spaces). Providing a tool with a space in the name can cause silent failures or unexpected behavior during the "Reason-Act" loop. This fix catches the error at instantiation time, providing a clear guidance to the developer to use underscores instead.
Test Coverage:
BaseTool(name="valid_name", ...)passes.BaseTool(name="invalid name", ...)raises ValueError.