feat: Use json schema for IntegrationConnectorTool declaration when feature enabled

Co-authored-by: Xuan Yang <xygoogle@google.com>
PiperOrigin-RevId: 856508415
This commit is contained in:
Xuan Yang
2026-01-14 23:09:44 -08:00
committed by Copybara-Service
parent ec6abf4010
commit 2ed686527a
2 changed files with 35 additions and 4 deletions
@@ -18,6 +18,8 @@ from google.adk.auth.auth_credential import AuthCredential
from google.adk.auth.auth_credential import AuthCredentialTypes
from google.adk.auth.auth_credential import HttpAuth
from google.adk.auth.auth_credential import HttpCredentials
from google.adk.features import FeatureName
from google.adk.features._feature_registry import temporary_feature_override
from google.adk.tools.application_integration_tool.integration_connector_tool import IntegrationConnectorTool
from google.adk.tools.openapi_tool.openapi_spec_parser.rest_api_tool import RestApiTool
from google.adk.tools.openapi_tool.openapi_spec_parser.tool_auth_handler import AuthPreparationResult
@@ -254,3 +256,23 @@ async def test_run_with_auth_async(
args=expected_call_args, tool_context={}
)
assert result == {"status": "success", "data": "mock_data"}
def test_get_declaration_with_json_schema_feature_enabled(integration_tool):
"""Tests the generation of the function declaration with JSON schema feature enabled."""
with temporary_feature_override(FeatureName.JSON_SCHEMA_FOR_FUNC_DECL, True):
declaration = integration_tool._get_declaration()
assert isinstance(declaration, FunctionDeclaration)
assert declaration.name == "test_integration_tool"
assert declaration.description == "Test integration tool description."
assert declaration.parameters is None
assert declaration.parameters_json_schema == {
"type": "object",
"properties": {
"user_id": {"type": "string", "description": "User ID"},
"page_size": {"type": "integer"},
"filter": {"type": "string"},
},
"required": ["user_id"],
}