Skip to content

Conversation

zachgiordano
Copy link

@zachgiordano zachgiordano commented Aug 30, 2025

description

feat: Add wrapper for griptape tool: https://github.com/griptape-ai/griptape

Example:

from griptape.tools import WebScraperTool
from google.adk.tools.griptape_tool import GriptapeTool

scraper_tool = WebScraperTool()
wrapped_tool = GriptapeTool(scraper_tool)

# Or wrap a specific activity method:
wrapped_tool = GriptapeTool(scraper_tool, activity_method="scrape_url")

testing plan

  • Added unit tests for covering the Griptape tool wrapping integration

Closes: #2800

Copy link

@gemini-code-assist gemini-code-assist bot left a comment

Choose a reason for hiding this comment

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

Summary of Changes

Hello @zachgiordano, I'm Gemini Code Assist1! I'm currently reviewing this pull request and will post my feedback shortly. In the meantime, here's a summary to help you and other reviewers quickly get up to speed!

This pull request introduces a new GriptapeTool wrapper, enabling seamless integration of Griptape's robust tool ecosystem into the existing framework. This allows the system to leverage Griptape's pre-built tools for various tasks by converting their activity methods into a compatible format for generative AI function calling.

Highlights

  • New Griptape Tool Wrapper: Introduces GriptapeTool, an adapter class that allows integrating Griptape BaseTool instances with the ADK's generative AI function calling interface.
  • Dynamic Method Wrapping: The GriptapeTool dynamically wraps Griptape's @activity methods, parsing their schemas to correctly map parameters for ADK compatibility.
  • Dependency Update: Adds griptape>=1.8.2 as a new dependency in pyproject.toml for both testing and extensions.
  • Comprehensive Testing: Includes new unit tests (test_griptape_tool.py) to ensure proper initialization, function declaration generation, and execution of wrapped Griptape tools with various schemas.
Using Gemini Code Assist

The full guide for Gemini Code Assist can be found on our documentation page, here are some quick tips.

Invoking Gemini

You can request assistance from Gemini at any point in your pull request via creating an issue comment (i.e. comment on the pull request page) using either /gemini <command> or @gemini-code-assist <command>. Below is a summary of the supported commands.

Feature Command Description
Code Review /gemini review Performs a code review for the current pull request in its current state.
Pull Request Summary /gemini summary Provides a summary of the current pull request in its current state.
Comment @gemini-code-assist Responds in comments when explicitly tagged, both in issue comments and review comments.
Help /gemini help Displays a list of available commands.

Customization

To customize Gemini Code Assist for GitHub experience, repository maintainers can create a configuration file and/or provide a custom code review style guide (such as PEP-8 for Python) by creating and adding files to a .gemini/ folder in the base of the repository. Detailed instructions can be found here.

Limitations & Feedback

Gemini Code Assist may make mistakes. Please leave feedback on any instances where its feedback is incorrect or counter productive. You can react with 👍 and 👎 on @gemini-code-assist comments. If you're interested in giving your feedback about your experience with Gemini Code Assist for Github and other Google products, sign up here.

You can also get AI-powered code generation, chat, as well as code reviews directly in the IDE at no cost with the Gemini Code Assist IDE Extension.

Footnotes

  1. Review the Privacy Notices, Generative AI Prohibited Use Policy, Terms of Service, and learn how to configure Gemini Code Assist in GitHub here. Gemini can make mistakes, so double check it and use code with caution.

@adk-bot
Copy link
Collaborator

adk-bot commented Aug 30, 2025

Hello @zachgiordano, thank you for creating this PR!

This PR is a new feature, could you please associate a GitHub issue with this PR? If there is no existing issue, could you please create one?

In addition, could you please include a testing plan section in your PR to talk about how you will test your changes?

This information will help reviewers to review your PR more efficiently. Thanks!

Response from ADK Triaging Agent

@adk-bot adk-bot added bot triaged [Bot] This issue is triaged by ADK bot tools [Component] This issue is related to tools labels Aug 30, 2025
@adk-bot adk-bot requested a review from seanzhou1023 August 30, 2025 21:41
Copy link

@gemini-code-assist gemini-code-assist bot left a comment

Choose a reason for hiding this comment

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

Code Review

This pull request introduces a wrapper for Griptape tools, allowing them to be used within the ADK framework. The changes include adding the griptape dependency, implementing the GriptapeTool wrapper class, and providing unit tests. The implementation is mostly solid, but I have identified a few areas for improvement regarding type safety, exception handling, and a functional limitation in the configuration-based setup that prevents selecting a specific tool activity when multiple are present. My feedback includes suggestions to address these points to make the wrapper more robust and flexible.

Comment on lines 240 to 253
def from_config(
cls: type[GriptapeTool], config: ToolArgsConfig, config_abs_path: str
) -> GriptapeTool:
from ..agents import config_agent_utils

griptape_tool_config = GriptapeToolConfig.model_validate(
config.model_dump()
)
tool = config_agent_utils.resolve_fully_qualified_name(
griptape_tool_config.tool
)
name = griptape_tool_config.name
description = griptape_tool_config.description
return cls(tool, name=name, description=description)

Choose a reason for hiding this comment

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

high

The current implementation of from_config and GriptapeToolConfig does not allow specifying the activity_method from the configuration. If a Griptape tool has multiple @activity decorated methods, this wrapper will always select the first one it finds, which is a significant limitation.

To provide more flexibility, I recommend the following changes:

  1. Add an optional activity_method: Optional[str] = None field to the GriptapeToolConfig class.
  2. Update this from_config method to read the activity_method from the config and pass it to the GriptapeTool constructor.

Comment on lines 59 to 68
_griptape_tool: Any
"""The wrapped griptape tool."""

def __init__(
self,
tool: Any,
activity_method: Optional[str] = None,
name: Optional[str] = None,
description: Optional[str] = None,
):

Choose a reason for hiding this comment

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

medium

The type hints for _griptape_tool and the tool parameter in __init__ are Any. Since the code expects and validates that the tool is a GriptapeBaseTool, using this more specific type in the hints would improve type safety and code clarity.

Suggested change
_griptape_tool: Any
"""The wrapped griptape tool."""
def __init__(
self,
tool: Any,
activity_method: Optional[str] = None,
name: Optional[str] = None,
description: Optional[str] = None,
):
_griptape_tool: GriptapeBaseTool
"""The wrapped griptape tool."""
def __init__(
self,
tool: GriptapeBaseTool,
activity_method: Optional[str] = None,
name: Optional[str] = None,
description: Optional[str] = None,
):

Comment on lines 167 to 170
except Exception as e:
# If schema parsing fails, fall back to empty params
print(f'Warning: Could not parse Griptape schema: {e}')
return {}

Choose a reason for hiding this comment

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

medium

This exception handling could be improved:

  • Broad Exception: Catching a generic Exception can hide unexpected errors. It's better to catch more specific exceptions that you anticipate during schema parsing (e.g., AttributeError, KeyError, TypeError).
  • Using print: print() should be avoided for logging in a library. The logging module provides proper logging that can be configured by the application.

Please consider refining the exception handling and using logging.warning. You will need to import the logging module.

Suggested change
except Exception as e:
# If schema parsing fails, fall back to empty params
print(f'Warning: Could not parse Griptape schema: {e}')
return {}
except (AttributeError, KeyError, TypeError) as e:
# If schema parsing fails, fall back to empty params
logging.warning('Could not parse Griptape schema: %s', e)
return {}

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bot triaged [Bot] This issue is triaged by ADK bot tools [Component] This issue is related to tools
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Griptape Tool Wrapper
2 participants