Skip to content

fix(a2a): stop to_a2a from overriding the application's log level - #7463

Open
ankit2235 wants to merge 1 commit into
google:mainfrom
ankit2235:fix/a2a-keep-log-level
Open

ankit2235 wants to merge 1 commit into
google:mainfrom
ankit2235:fix/a2a-keep-log-level

Conversation

@ankit2235

Copy link
Copy Markdown

Link to Issue or Description of Change

1. Link to an existing issue (if applicable):

Problem:
to_a2a() sets the google_adk logger to INFO every time it's called. Any level the application configured beforehand gets overwritten, e.g. a uvicorn --log-config that sets google_adk to DEBUG loses all ADK debug output once the module calls to_a2a(), and a WARNING level starts letting INFO through again.

The comment said the call was there so logs show up when running under uvicorn directly, but uvicorn's default config doesn't attach a root handler, so ADK INFO records weren't printed with or without it.

Solution:
Remove the setLevel call and leave log levels to the application. The adk_logger variable stays since two warnings further down still use it.

One behavior change to be aware of: an app that sets up its own root handler but never sets a level on google_adk will no longer see ADK's INFO lines after calling to_a2a(). That matches what the app configured, but if you'd prefer to keep INFO as a default, I can change this to only set the level when google_adk is still NOTSET.

Testing Plan

Unit Tests:

  • I have added or updated unit tests for my change.
  • All unit tests pass locally.

Added test_to_a2a_keeps_configured_adk_log_level. It fails on main (assert 20 == 30, i.e. INFO instead of WARNING) and passes with the fix.

pytest tests/unittests/a2a/utils/test_agent_to_a2a.py -q
46 passed, 2 skipped

pytest tests/unittests/a2a -q
892 passed, 51 skipped

Manual End-to-End (E2E) Tests:

A small module that logs at DEBUG before and after calling to_a2a(), served with uvicorn and a log config that sets google_adk to DEBUG:

log = logging.getLogger("google_adk.probe")
log.debug("DEBUG before to_a2a")
a2a_app = to_a2a(LlmAgent(name="probe", model="gemini-2.5-flash"), port=8799)
log.debug("DEBUG after to_a2a")
uvicorn app_mod:a2a_app --port 8799 --log-config log.json

Before the fix:

DEBUG before to_a2a

After the fix:

DEBUG before to_a2a
DEBUG after to_a2a

Checklist

  • I have read the CONTRIBUTING.md document.
  • I have performed a self-review of my own code.
  • I have commented my code, particularly in hard-to-understand areas.
  • I have added tests that prove my fix is effective or that my feature works.
  • New and existing unit tests pass locally with my changes.
  • I have manually tested my changes end-to-end.
  • Any dependent changes have been merged and published in downstream modules.

to_a2a() set the "google_adk" logger to INFO on every call, so a level
the application configured before building the app (for example with
`uvicorn --log-config`) was silently replaced: DEBUG logs disappeared
and a WARNING setting started letting INFO through.

The override did not make logs visible under plain uvicorn either:
uvicorn's default config adds no root handler, so ADK INFO records were
dropped with or without it. Leave the level to the application.

Fixes google#7462
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

to_a2a() overrides the google_adk logger level set by the application

1 participant