From 671155ef6d106e61adbdf402520dc481c167403d Mon Sep 17 00:00:00 2001 From: "Optimus (AI Agent)" Date: Thu, 5 Mar 2026 15:39:37 +0000 Subject: [PATCH 1/4] fix: suppress repetitive A2A experimental mode warnings The upstream google-adk A2A components emit UserWarning messages about experimental mode on every operation, flooding agent logs. This adds warnings.filterwarnings() to suppress these known upstream warnings at module import time. Fixes #1379 Co-Authored-By: Claude Opus 4.6 Signed-off-by: Optimus (AI Agent) --- python/packages/kagent-adk/src/kagent/adk/_agent_executor.py | 4 ++++ python/packages/kagent-adk/src/kagent/adk/types.py | 4 ++++ 2 files changed, 8 insertions(+) diff --git a/python/packages/kagent-adk/src/kagent/adk/_agent_executor.py b/python/packages/kagent-adk/src/kagent/adk/_agent_executor.py index a4ac5e280..96b897aba 100644 --- a/python/packages/kagent-adk/src/kagent/adk/_agent_executor.py +++ b/python/packages/kagent-adk/src/kagent/adk/_agent_executor.py @@ -4,6 +4,7 @@ import inspect import logging import uuid +import warnings from contextlib import suppress from datetime import datetime, timezone from typing import Any, Awaitable, Callable, Optional @@ -21,6 +22,9 @@ TaskStatusUpdateEvent, TextPart, ) + +# Suppress repetitive experimental mode warnings from upstream ADK A2A support (#1379) +warnings.filterwarnings("ignore", message=r"\[EXPERIMENTAL\].*A2A") from google.adk.a2a.executor.a2a_agent_executor import ( A2aAgentExecutor as UpstreamA2aAgentExecutor, ) diff --git a/python/packages/kagent-adk/src/kagent/adk/types.py b/python/packages/kagent-adk/src/kagent/adk/types.py index 26b3df144..6c2d7d529 100644 --- a/python/packages/kagent-adk/src/kagent/adk/types.py +++ b/python/packages/kagent-adk/src/kagent/adk/types.py @@ -1,4 +1,5 @@ import logging +import warnings from typing import Any, Callable, Literal, Optional, Union import httpx @@ -7,6 +8,9 @@ from google.adk.agents.callback_context import CallbackContext from google.adk.agents.llm_agent import ToolUnion from google.adk.agents.readonly_context import ReadonlyContext + +# Suppress repetitive experimental mode warnings from upstream ADK A2A support (#1379) +warnings.filterwarnings("ignore", message=r"\[EXPERIMENTAL\].*A2A") from google.adk.agents.remote_a2a_agent import AGENT_CARD_WELL_KNOWN_PATH, DEFAULT_TIMEOUT, RemoteA2aAgent from google.adk.models.anthropic_llm import Claude as ClaudeLLM from google.adk.models.google_llm import Gemini as GeminiLLM From e9c401f52ec82ef7d4122cc4d5be25d92a63e84c Mon Sep 17 00:00:00 2001 From: "Optimus (AI Agent)" Date: Fri, 6 Mar 2026 11:11:20 +0000 Subject: [PATCH 2/4] fix: use action='once' for A2A warnings and remove duplicate filter - Change filterwarnings from "ignore" to "once" so users see the experimental warning once per process instead of never - Remove duplicate filter from _agent_executor.py since types.py (imported earlier) already installs it - Add unit test verifying duplicate warnings are suppressed Co-Authored-By: Claude Opus 4.6 Signed-off-by: Optimus (AI Agent) --- .../src/kagent/adk/_agent_executor.py | 4 +--- .../kagent-adk/src/kagent/adk/types.py | 4 ++-- .../unittests/test_a2a_warning_filter.py | 21 +++++++++++++++++++ 3 files changed, 24 insertions(+), 5 deletions(-) create mode 100644 python/packages/kagent-adk/tests/unittests/test_a2a_warning_filter.py diff --git a/python/packages/kagent-adk/src/kagent/adk/_agent_executor.py b/python/packages/kagent-adk/src/kagent/adk/_agent_executor.py index 96b897aba..afdad5de7 100644 --- a/python/packages/kagent-adk/src/kagent/adk/_agent_executor.py +++ b/python/packages/kagent-adk/src/kagent/adk/_agent_executor.py @@ -4,7 +4,6 @@ import inspect import logging import uuid -import warnings from contextlib import suppress from datetime import datetime, timezone from typing import Any, Awaitable, Callable, Optional @@ -23,8 +22,7 @@ TextPart, ) -# Suppress repetitive experimental mode warnings from upstream ADK A2A support (#1379) -warnings.filterwarnings("ignore", message=r"\[EXPERIMENTAL\].*A2A") +# Warning filter installed in types.py (imported before this module) from google.adk.a2a.executor.a2a_agent_executor import ( A2aAgentExecutor as UpstreamA2aAgentExecutor, ) diff --git a/python/packages/kagent-adk/src/kagent/adk/types.py b/python/packages/kagent-adk/src/kagent/adk/types.py index 6c2d7d529..986f50001 100644 --- a/python/packages/kagent-adk/src/kagent/adk/types.py +++ b/python/packages/kagent-adk/src/kagent/adk/types.py @@ -9,8 +9,8 @@ from google.adk.agents.llm_agent import ToolUnion from google.adk.agents.readonly_context import ReadonlyContext -# Suppress repetitive experimental mode warnings from upstream ADK A2A support (#1379) -warnings.filterwarnings("ignore", message=r"\[EXPERIMENTAL\].*A2A") +# Show the A2A experimental warning once per process instead of on every call (#1379) +warnings.filterwarnings("once", message=r"\[EXPERIMENTAL\].*A2A") from google.adk.agents.remote_a2a_agent import AGENT_CARD_WELL_KNOWN_PATH, DEFAULT_TIMEOUT, RemoteA2aAgent from google.adk.models.anthropic_llm import Claude as ClaudeLLM from google.adk.models.google_llm import Gemini as GeminiLLM diff --git a/python/packages/kagent-adk/tests/unittests/test_a2a_warning_filter.py b/python/packages/kagent-adk/tests/unittests/test_a2a_warning_filter.py new file mode 100644 index 000000000..2beabaabd --- /dev/null +++ b/python/packages/kagent-adk/tests/unittests/test_a2a_warning_filter.py @@ -0,0 +1,21 @@ +"""Test that A2A experimental warnings are shown once, not on every import.""" + +import warnings + + +def test_a2a_warning_shown_once(): + """Importing types installs a 'once' filter for A2A experimental warnings.""" + # Reset warning filters to baseline + with warnings.catch_warnings(record=True) as caught: + warnings.simplefilter("always") + + # Re-install the filter as types.py does at import time + warnings.filterwarnings("once", message=r"\[EXPERIMENTAL\].*A2A") + + # First warning should be recorded + warnings.warn("[EXPERIMENTAL] A2A support is experimental", stacklevel=1) + assert len(caught) == 1 + + # Second identical warning should be suppressed + warnings.warn("[EXPERIMENTAL] A2A support is experimental", stacklevel=1) + assert len(caught) == 1, "Duplicate A2A warning was not suppressed" From 728c2502b6c93ae4dc203ccbc0436f6d43facc8d Mon Sep 17 00:00:00 2001 From: "Optimus (AI Agent)" Date: Wed, 11 Mar 2026 19:18:20 +0000 Subject: [PATCH 3/4] fix: scope A2A warning filter to UserWarning from google.adk modules Address remaining Copilot review feedback: - Add category=UserWarning and module=r"^google\.adk\." to filterwarnings() so the filter only affects A2A warnings from upstream ADK modules, not unrelated warnings from other packages - Add isort:off/on guards to prevent import reordering by ruff - Update tests to verify scoping: warnings from google.adk are deduplicated while warnings from other modules pass through Co-Authored-By: Claude Opus 4.6 Signed-off-by: Optimus (AI Agent) --- .../kagent-adk/src/kagent/adk/types.py | 9 ++-- .../unittests/test_a2a_warning_filter.py | 51 +++++++++++++++---- 2 files changed, 48 insertions(+), 12 deletions(-) diff --git a/python/packages/kagent-adk/src/kagent/adk/types.py b/python/packages/kagent-adk/src/kagent/adk/types.py index 986f50001..3c1543a8d 100644 --- a/python/packages/kagent-adk/src/kagent/adk/types.py +++ b/python/packages/kagent-adk/src/kagent/adk/types.py @@ -9,9 +9,12 @@ from google.adk.agents.llm_agent import ToolUnion from google.adk.agents.readonly_context import ReadonlyContext -# Show the A2A experimental warning once per process instead of on every call (#1379) -warnings.filterwarnings("once", message=r"\[EXPERIMENTAL\].*A2A") -from google.adk.agents.remote_a2a_agent import AGENT_CARD_WELL_KNOWN_PATH, DEFAULT_TIMEOUT, RemoteA2aAgent +# isort: off +# Show the A2A experimental warning once per process instead of on every call (#1379). +# Scoped to UserWarning from google.adk modules to avoid suppressing unrelated warnings. +warnings.filterwarnings("once", message=r"\[EXPERIMENTAL\].*A2A", category=UserWarning, module=r"^google\.adk\.") +from google.adk.agents.remote_a2a_agent import AGENT_CARD_WELL_KNOWN_PATH, DEFAULT_TIMEOUT, RemoteA2aAgent # noqa: E402 +# isort: on from google.adk.models.anthropic_llm import Claude as ClaudeLLM from google.adk.models.google_llm import Gemini as GeminiLLM from google.adk.tools.agent_tool import AgentTool diff --git a/python/packages/kagent-adk/tests/unittests/test_a2a_warning_filter.py b/python/packages/kagent-adk/tests/unittests/test_a2a_warning_filter.py index 2beabaabd..e19134375 100644 --- a/python/packages/kagent-adk/tests/unittests/test_a2a_warning_filter.py +++ b/python/packages/kagent-adk/tests/unittests/test_a2a_warning_filter.py @@ -4,18 +4,51 @@ def test_a2a_warning_shown_once(): - """Importing types installs a 'once' filter for A2A experimental warnings.""" - # Reset warning filters to baseline + """Importing types installs a scoped 'once' filter for A2A experimental warnings.""" with warnings.catch_warnings(record=True) as caught: warnings.simplefilter("always") - # Re-install the filter as types.py does at import time - warnings.filterwarnings("once", message=r"\[EXPERIMENTAL\].*A2A") + # Re-install the filter as types.py does at import time (scoped to google.adk) + warnings.filterwarnings( + "once", + message=r"\[EXPERIMENTAL\].*A2A", + category=UserWarning, + module=r"^google\.adk\.", + ) - # First warning should be recorded - warnings.warn("[EXPERIMENTAL] A2A support is experimental", stacklevel=1) + # Simulate a warning from a google.adk module by executing in a + # namespace whose __name__ matches the module filter. + adk_globals = {"__name__": "google.adk.a2a.remote", "__file__": __file__} + code = compile( + 'import warnings; warnings.warn("[EXPERIMENTAL] A2A support is experimental", UserWarning, stacklevel=1)', + "", + "exec", + ) + + exec(code, adk_globals) # noqa: S102 + assert len(caught) == 1, "First A2A warning should be recorded" + + exec(code, adk_globals) # noqa: S102 + assert len(caught) == 1, "Duplicate A2A warning from google.adk should be suppressed" + + +def test_filter_does_not_suppress_non_adk_warnings(): + """The filter should not suppress warnings from modules outside google.adk.""" + with warnings.catch_warnings(record=True) as caught: + warnings.simplefilter("always") + + # Install the scoped filter + warnings.filterwarnings( + "once", + message=r"\[EXPERIMENTAL\].*A2A", + category=UserWarning, + module=r"^google\.adk\.", + ) + + # A warning from the current test module (not google.adk.*) should not be suppressed + warnings.warn("[EXPERIMENTAL] A2A support is experimental", UserWarning, stacklevel=1) assert len(caught) == 1 - # Second identical warning should be suppressed - warnings.warn("[EXPERIMENTAL] A2A support is experimental", stacklevel=1) - assert len(caught) == 1, "Duplicate A2A warning was not suppressed" + warnings.warn("[EXPERIMENTAL] A2A support is experimental", UserWarning, stacklevel=1) + # Both should be recorded because this module is not google.adk.* + assert len(caught) == 2, "Warnings from non-google.adk modules should not be suppressed" From d042ecc8f75393b46e207bf83952d713255683ae Mon Sep 17 00:00:00 2001 From: "Optimus (AI Agent)" Date: Wed, 11 Mar 2026 19:34:06 +0000 Subject: [PATCH 4/4] fix: narrow A2A warning filter to exact remote_a2a_agent module Address Copilot review: scope the module regex from the broad `^google\.adk\.` prefix to the exact `^google\.adk\.agents\.remote_a2a_agent$` module where the warning originates. This prevents accidentally suppressing experimental warnings from other google.adk submodules. Also adds a test verifying that warnings from other google.adk modules are not affected by the filter. Co-Authored-By: Claude Opus 4.6 Signed-off-by: Optimus (AI Agent) --- .../kagent-adk/src/kagent/adk/types.py | 9 +++- .../unittests/test_a2a_warning_filter.py | 50 +++++++++++++++---- 2 files changed, 47 insertions(+), 12 deletions(-) diff --git a/python/packages/kagent-adk/src/kagent/adk/types.py b/python/packages/kagent-adk/src/kagent/adk/types.py index 3c1543a8d..a6a36c29c 100644 --- a/python/packages/kagent-adk/src/kagent/adk/types.py +++ b/python/packages/kagent-adk/src/kagent/adk/types.py @@ -11,8 +11,13 @@ # isort: off # Show the A2A experimental warning once per process instead of on every call (#1379). -# Scoped to UserWarning from google.adk modules to avoid suppressing unrelated warnings. -warnings.filterwarnings("once", message=r"\[EXPERIMENTAL\].*A2A", category=UserWarning, module=r"^google\.adk\.") +# Scoped to UserWarning from the specific remote_a2a_agent module to avoid suppressing unrelated warnings. +warnings.filterwarnings( + "once", + message=r"\[EXPERIMENTAL\].*A2A", + category=UserWarning, + module=r"^google\.adk\.agents\.remote_a2a_agent$", +) from google.adk.agents.remote_a2a_agent import AGENT_CARD_WELL_KNOWN_PATH, DEFAULT_TIMEOUT, RemoteA2aAgent # noqa: E402 # isort: on from google.adk.models.anthropic_llm import Claude as ClaudeLLM diff --git a/python/packages/kagent-adk/tests/unittests/test_a2a_warning_filter.py b/python/packages/kagent-adk/tests/unittests/test_a2a_warning_filter.py index e19134375..76b4208a8 100644 --- a/python/packages/kagent-adk/tests/unittests/test_a2a_warning_filter.py +++ b/python/packages/kagent-adk/tests/unittests/test_a2a_warning_filter.py @@ -8,17 +8,18 @@ def test_a2a_warning_shown_once(): with warnings.catch_warnings(record=True) as caught: warnings.simplefilter("always") - # Re-install the filter as types.py does at import time (scoped to google.adk) + # Re-install the filter as types.py does at import time + # (scoped to the specific remote_a2a_agent module) warnings.filterwarnings( "once", message=r"\[EXPERIMENTAL\].*A2A", category=UserWarning, - module=r"^google\.adk\.", + module=r"^google\.adk\.agents\.remote_a2a_agent$", ) - # Simulate a warning from a google.adk module by executing in a + # Simulate a warning from the exact upstream module by executing in a # namespace whose __name__ matches the module filter. - adk_globals = {"__name__": "google.adk.a2a.remote", "__file__": __file__} + adk_globals = {"__name__": "google.adk.agents.remote_a2a_agent", "__file__": __file__} code = compile( 'import warnings; warnings.warn("[EXPERIMENTAL] A2A support is experimental", UserWarning, stacklevel=1)', "", @@ -29,11 +30,11 @@ def test_a2a_warning_shown_once(): assert len(caught) == 1, "First A2A warning should be recorded" exec(code, adk_globals) # noqa: S102 - assert len(caught) == 1, "Duplicate A2A warning from google.adk should be suppressed" + assert len(caught) == 1, "Duplicate A2A warning from remote_a2a_agent should be suppressed" def test_filter_does_not_suppress_non_adk_warnings(): - """The filter should not suppress warnings from modules outside google.adk.""" + """The filter should not suppress warnings from modules outside remote_a2a_agent.""" with warnings.catch_warnings(record=True) as caught: warnings.simplefilter("always") @@ -42,13 +43,42 @@ def test_filter_does_not_suppress_non_adk_warnings(): "once", message=r"\[EXPERIMENTAL\].*A2A", category=UserWarning, - module=r"^google\.adk\.", + module=r"^google\.adk\.agents\.remote_a2a_agent$", ) - # A warning from the current test module (not google.adk.*) should not be suppressed + # A warning from the current test module (not remote_a2a_agent) should not be suppressed warnings.warn("[EXPERIMENTAL] A2A support is experimental", UserWarning, stacklevel=1) assert len(caught) == 1 warnings.warn("[EXPERIMENTAL] A2A support is experimental", UserWarning, stacklevel=1) - # Both should be recorded because this module is not google.adk.* - assert len(caught) == 2, "Warnings from non-google.adk modules should not be suppressed" + # Both should be recorded because this module is not google.adk.agents.remote_a2a_agent + assert len(caught) == 2, "Warnings from non-remote_a2a_agent modules should not be suppressed" + + +def test_filter_does_not_suppress_other_adk_modules(): + """The filter should not suppress warnings from other google.adk submodules.""" + with warnings.catch_warnings(record=True) as caught: + warnings.simplefilter("always") + + # Install the scoped filter (exact module match only) + warnings.filterwarnings( + "once", + message=r"\[EXPERIMENTAL\].*A2A", + category=UserWarning, + module=r"^google\.adk\.agents\.remote_a2a_agent$", + ) + + # A warning from a different google.adk submodule should NOT be suppressed + other_adk_globals = {"__name__": "google.adk.a2a.executor", "__file__": __file__} + code = compile( + 'import warnings; warnings.warn("[EXPERIMENTAL] A2A support is experimental", UserWarning, stacklevel=1)', + "", + "exec", + ) + + exec(code, other_adk_globals) # noqa: S102 + assert len(caught) == 1 + + exec(code, other_adk_globals) # noqa: S102 + # Both should be recorded because the module doesn't match remote_a2a_agent exactly + assert len(caught) == 2, "Warnings from other google.adk modules should not be suppressed"