fix: suppress repeated A2A experimental mode warnings#1395
fix: suppress repeated A2A experimental mode warnings#1395fl-sean03 wants to merge 1 commit intokagent-dev:mainfrom
Conversation
There was a problem hiding this comment.
Pull request overview
This PR reduces log spam when using A2A tools by ensuring the upstream google-adk experimental-mode UserWarning emitted by RemoteA2aAgent is only shown once per process.
Changes:
- Added a module-level
warnings.filterwarnings("once", ...)rule targeting the[EXPERIMENTAL] ... A2A supportwarning. - Added the
warningsimport required for the new filter.
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
| # The warning is useful on first occurrence but floods logs when creating | ||
| # multiple remote agent instances. See: https://github.com/kagent-dev/kagent/issues/1379 | ||
| warnings.filterwarnings( | ||
| "once", message=r"\[EXPERIMENTAL\].*A2A support", category=UserWarning |
There was a problem hiding this comment.
warnings.filterwarnings() prepends to the global warnings filter by default, which can override application/user warning configuration (e.g., PYTHONWARNINGS/warnings.simplefilter). Consider adding append=True so explicit user filters take precedence, and also scoping the filter with the module= regex (e.g., the google-adk remote_a2a_agent module) to avoid suppressing unrelated [EXPERIMENTAL] ... A2A support UserWarnings from other sources.
| "once", message=r"\[EXPERIMENTAL\].*A2A support", category=UserWarning | |
| "once", | |
| message=r"\[EXPERIMENTAL\].*A2A support", | |
| category=UserWarning, | |
| module=r"^google\.adk\.agents\.remote_a2a_agent$", | |
| append=True, |
| # The warning is useful on first occurrence but floods logs when creating | ||
| # multiple remote agent instances. See: https://github.com/kagent-dev/kagent/issues/1379 | ||
| warnings.filterwarnings( | ||
| "once", message=r"\[EXPERIMENTAL\].*A2A support", category=UserWarning |
There was a problem hiding this comment.
This warnings.filterwarnings(...) call isn’t formatted consistently with the rest of the file (ruff/black style). Since CI runs ruff format --diff, please run the formatter so this block matches the repository’s formatting (likely one-line or multi-line with trailing commas).
| "once", message=r"\[EXPERIMENTAL\].*A2A support", category=UserWarning | |
| "once", | |
| message=r"\[EXPERIMENTAL\].*A2A support", | |
| category=UserWarning, |
Add warnings.filterwarnings("once") to show the upstream google-adk
A2A experimental warning exactly once instead of on every
RemoteA2aAgent instantiation.
Fixes kagent-dev#1379
Signed-off-by: Sean Florez <sean@opspawn.com>
Signed-off-by: fl-sean03 <jmhbh@users.noreply.github.com>
59b7f24 to
a47f648
Compare
|
Closing in favor of #1388 which was opened first. Happy to help iterate on that PR if needed. |
Fixes #1379
Problem
When using A2A tools, the upstream
google-adkRemoteA2aAgentclass is decorated with@a2a_experimental, which emits aUserWarningon every instantiation. Since kagent creates multipleRemoteA2aAgentinstances (one perremote_agent), this floods logs with repeated[EXPERIMENTAL] RemoteA2aAgent: ADK Implementation for A2A support...warnings.Fix
Add
warnings.filterwarnings("once", ...)at module level intypes.pyto show the upstream experimental warning exactly once instead of on everyRemoteA2aAgentconstruction. The filter matches the specific[EXPERIMENTAL]...A2A supportmessage pattern.This is idiomatic Python —
warnings.filterwarnings("once")is the standard mechanism for deduplicating repeated warnings. The warning still appears on first occurrence so users know A2A support is experimental.Changes
python/packages/kagent-adk/src/kagent/adk/types.py: Addedimport warningsand afilterwarnings("once")call targeting the A2A experimental warning.Signed-off-by: Sean Florez sean@opspawn.com