Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,7 @@ def __init__(
auth_scheme: Optional[AuthScheme] = None,
auth_credential: Optional[AuthCredential] = None,
tool_filter: Optional[Union[ToolPredicate, List[str]]] = None,
tool_name_prefix: Optional[str] = None,
ssl_verify: Optional[Union[bool, str, ssl.SSLContext]] = None,
):
"""Initializes the OpenAPIToolset.
Expand Down Expand Up @@ -104,6 +105,9 @@ def __init__(
``google.adk.tools.openapi_tool.auth.auth_helpers``
tool_filter: The filter used to filter the tools in the toolset. It can be
either a tool predicate or a list of tool names of the tools to expose.
tool_name_prefix: The prefix to prepend to the names of the tools returned
by the toolset. Useful when multiple OpenAPI specs have tools with
similar names.
ssl_verify: SSL certificate verification option for all tools. Can be:
- None: Use default verification (True)
- True: Verify SSL certificates using system CA
Expand All @@ -113,7 +117,7 @@ def __init__(
This is useful for enterprise environments where requests go through
a TLS-intercepting proxy with a custom CA certificate.
"""
super().__init__(tool_filter=tool_filter)
super().__init__(tool_filter=tool_filter, tool_name_prefix=tool_name_prefix)
if not spec_dict:
spec_dict = self._load_spec(spec_str, spec_str_type)
self._ssl_verify = ssl_verify
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -169,3 +169,24 @@ def test_openapi_toolset_configure_verify_all(openapi_spec: Dict[str, Any]):

for tool in toolset._tools:
assert tool._ssl_verify == ca_bundle_path


async def test_openapi_toolset_tool_name_prefix(openapi_spec: Dict[str, Any]):
"""Test tool_name_prefix parameter prefixes tool names."""
prefix = "my_api"
toolset = OpenAPIToolset(spec_dict=openapi_spec, tool_name_prefix=prefix)

# Verify the toolset has the prefix set
assert toolset.tool_name_prefix == prefix

prefixed_tools = await toolset.get_tools_with_prefix()
assert len(prefixed_tools) == 5

# Verify all tool names are prefixed
for tool in prefixed_tools:
assert tool.name.startswith(f"{prefix}_")

# Verify specific tool name is prefixed
expected_prefixed_name = "my_api_calendar_calendars_insert"
prefixed_tool_names = [t.name for t in prefixed_tools]
assert expected_prefixed_name in prefixed_tool_names
Loading