From 37779cf5439c30b99304f04636b8ac513dcc1422 Mon Sep 17 00:00:00 2001 From: Vishal Bulbule Date: Sun, 20 Sep 2026 00:52:07 +0530 Subject: [PATCH] fix(flows): stop Agent import loading authlib, which fails test_import_loading _toolset_auth imported TOOLSET_AUTH_CREDENTIAL_ID_PREFIX from auth.auth_preprocessor at module level. That module imports AuthHandler and the OAuth2 credential exchanger, so `from google.adk.agents import Agent` started loading authlib, cryptography, requests and related packages at startup, which fails test_import_loading. Import the constant where it is used, as the module already does for CredentialManager and AuthHandler. --- src/google/adk/flows/llm_flows/tools/_toolset_auth.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/google/adk/flows/llm_flows/tools/_toolset_auth.py b/src/google/adk/flows/llm_flows/tools/_toolset_auth.py index 5c0d7e57da..a3c03c8b0d 100644 --- a/src/google/adk/flows/llm_flows/tools/_toolset_auth.py +++ b/src/google/adk/flows/llm_flows/tools/_toolset_auth.py @@ -24,7 +24,6 @@ from ....agents.callback_context import CallbackContext from ....agents.invocation_context import InvocationContext -from ....auth.auth_preprocessor import TOOLSET_AUTH_CREDENTIAL_ID_PREFIX from ....auth.auth_tool import AuthConfig from ....events.event import Event from ....models.llm_request import LlmRequest @@ -96,6 +95,8 @@ async def resolve_toolset_auth( invocation_context.credential_by_key[credential_key] = credential else: # Need auth - will interrupt + from ....auth.auth_preprocessor import TOOLSET_AUTH_CREDENTIAL_ID_PREFIX + toolset_id = ( f'{TOOLSET_AUTH_CREDENTIAL_ID_PREFIX}{type(tool_union).__name__}' )