From 8065361d646afcebfb6420816bec23f165ee3fe6 Mon Sep 17 00:00:00 2001 From: rcsantana777 Date: Wed, 20 Aug 2025 23:46:16 +0000 Subject: [PATCH 1/4] feat: Add custom User-Agent header to RestApiTool requests --- .../tools/openapi_tool/openapi_spec_parser/rest_api_tool.py | 6 ++++++ 1 file changed, 6 insertions(+) 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 0df9461b9d..6a367fd9d3 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 @@ -245,6 +245,8 @@ def _prepare_request_params( Example: self._prepare_request_params({"input_id": "test-id"}) """ + from .... import __version__ as adk_version + method = self.endpoint.method.lower() if not method: raise ValueError("Operation method not found.") @@ -254,6 +256,10 @@ def _prepare_request_params( header_params: Dict[str, Any] = {} cookie_params: Dict[str, Any] = {} + # Set the custom User-Agent header + user_agent = f"google-adk/{adk_version}" + header_params["User-Agent"] = user_agent + params_map: Dict[str, ApiParameter] = {p.py_name: p for p in parameters} # Fill in path, query, header and cookie parameters to the request From 396865db957e52858ae31326f034d2ffaae544c9 Mon Sep 17 00:00:00 2001 From: rcsantana777 Date: Fri, 22 Aug 2025 04:26:03 +0000 Subject: [PATCH 2/4] feat: Add dynamic User-Agent header to RestApiTool --- .../adk/tools/openapi_tool/openapi_spec_parser/rest_api_tool.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) 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 6a367fd9d3..c468775d30 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 @@ -245,7 +245,7 @@ def _prepare_request_params( Example: self._prepare_request_params({"input_id": "test-id"}) """ - from .... import __version__ as adk_version + from ....version import __version__ as adk_version method = self.endpoint.method.lower() if not method: From a51a8fb2ccd3f54e6c2069e078b6d1ac0af1b36b Mon Sep 17 00:00:00 2001 From: rcsantana777 Date: Fri, 22 Aug 2025 05:16:21 +0000 Subject: [PATCH 3/4] feat: Enhance User-Agent header to include tool name --- .../adk/tools/openapi_tool/openapi_spec_parser/rest_api_tool.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) 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 c468775d30..68e703f381 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 @@ -257,7 +257,7 @@ def _prepare_request_params( cookie_params: Dict[str, Any] = {} # Set the custom User-Agent header - user_agent = f"google-adk/{adk_version}" + user_agent = f"google-adk/{adk_version} (tool: {self.name})" header_params["User-Agent"] = user_agent params_map: Dict[str, ApiParameter] = {p.py_name: p for p in parameters} From a9a9375306c18bb7ba501276cbf76693e70a87ad Mon Sep 17 00:00:00 2001 From: rcsantana777 Date: Fri, 22 Aug 2025 05:38:41 +0000 Subject: [PATCH 4/4] feat: Enhance User-Agent to include tool name and refine import --- .../tools/openapi_tool/openapi_spec_parser/rest_api_tool.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) 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 68e703f381..2c02d55510 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 @@ -245,7 +245,6 @@ def _prepare_request_params( Example: self._prepare_request_params({"input_id": "test-id"}) """ - from ....version import __version__ as adk_version method = self.endpoint.method.lower() if not method: @@ -256,6 +255,8 @@ def _prepare_request_params( header_params: Dict[str, Any] = {} cookie_params: Dict[str, Any] = {} + from ....version import __version__ as adk_version + # Set the custom User-Agent header user_agent = f"google-adk/{adk_version} (tool: {self.name})" header_params["User-Agent"] = user_agent