diff --git a/src/google/adk/cli/cli_deploy.py b/src/google/adk/cli/cli_deploy.py index e7fed4a4ef1..ded0a47dc93 100644 --- a/src/google/adk/cli/cli_deploy.py +++ b/src/google/adk/cli/cli_deploy.py @@ -502,6 +502,7 @@ def _validate_agent_import( # Add parent directory to path so imports work correctly if parent_dir not in sys.path: sys.path.insert(0, parent_dir) + importlib.invalidate_caches() try: module = importlib.import_module(f'{module_name}.agent') except ImportError as e: diff --git a/src/google/adk/tools/openapi_tool/openapi_spec_parser/rest_api_tool.py b/src/google/adk/tools/openapi_tool/openapi_spec_parser/rest_api_tool.py index 61cb6a37e43..8e9a1ee18cb 100644 --- a/src/google/adk/tools/openapi_tool/openapi_spec_parser/rest_api_tool.py +++ b/src/google/adk/tools/openapi_tool/openapi_spec_parser/rest_api_tool.py @@ -394,7 +394,7 @@ def _prepare_request_params( if param_location == "path": path_params[original_k] = v elif param_location == "query": - if v: + if v is not None and v != "": query_params[original_k] = v elif param_location == "header": header_params[original_k] = v diff --git a/tests/unittests/tools/openapi_tool/openapi_spec_parser/test_rest_api_tool.py b/tests/unittests/tools/openapi_tool/openapi_spec_parser/test_rest_api_tool.py index ad72915e12b..9c22ce001a0 100644 --- a/tests/unittests/tools/openapi_tool/openapi_spec_parser/test_rest_api_tool.py +++ b/tests/unittests/tools/openapi_tool/openapi_spec_parser/test_rest_api_tool.py @@ -1052,6 +1052,49 @@ def test_prepare_request_params_no_credential( assert "param_name" in request_params["params"] assert "empty_param" not in request_params["params"] + def test_prepare_request_params_preserves_falsy_query_parameter_values( + self, + sample_endpoint, + sample_auth_credential, + sample_auth_scheme, + sample_operation, + ): + tool = RestApiTool( + name="test_tool", + description="Test Tool", + endpoint=sample_endpoint, + operation=sample_operation, + auth_credential=sample_auth_credential, + auth_scheme=sample_auth_scheme, + ) + params = [ + ApiParameter( + original_name="include_inactive", + py_name="include_inactive", + param_location="query", + param_schema=OpenAPISchema(type="boolean"), + ), + ApiParameter( + original_name="page", + py_name="page", + param_location="query", + param_schema=OpenAPISchema(type="integer"), + ), + ApiParameter( + original_name="empty_param", + py_name="empty_param", + param_location="query", + param_schema=OpenAPISchema(type="string"), + ), + ] + kwargs = {"include_inactive": False, "page": 0, "empty_param": ""} + + request_params = tool._prepare_request_params(params, kwargs) + + assert request_params["params"]["include_inactive"] is False + assert request_params["params"]["page"] == 0 + assert "empty_param" not in request_params["params"] + @pytest.mark.parametrize( "verify_input, expected_verify_in_call", [