fix(flows): stop Agent import loading authlib, which fails test_import_loading - #7214
Open
vishal-bulbule wants to merge 1 commit into
Open
vishal-bulbule wants to merge 1 commit into
vishal-bulbule wants to merge 1 commit into
Conversation
…t_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.
This was referenced Sep 19, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Link to Issue or Description of Change
1. Link to an existing issue (if applicable):
2. Or, if no issue exists, describe the change:
Problem:
Since 665ec98 ("refactor: extract tool-resolution steps into tool_request_processors"),
tests/unittests/test_import_loading.py::test_entry_point_loads_only_allowlisted_packagesfails on
main, and all five Unit Tests jobs (Python 3.10 to 3.14) fail on every CI run and on open PRs(latest main run: https://github.com/google/adk-python/actions/runs/35460464450):
The new
flows/llm_flows/tools/_toolset_auth.pyimportsTOOLSET_AUTH_CREDENTIAL_ID_PREFIXfromauth.auth_preprocessorat module level.auth_preprocessorimportsAuthHandler, which imports the OAuth2 credential exchanger andauthlib. Before the refactor,base_llm_flow.pydefined the constant itself, so nothingextra was loaded.
Solution:
Import the constant inside
resolve_toolset_auth, where it is used, as the module alreadydoes for
CredentialManagerandAuthHandler. One file, one import moved.Testing Plan
Unit Tests:
test_import_loading.py, which fails onmainand passes with this change)Bisected over the commits since f33d492: the import test passes up to 6605031 and fails from
665ec98 onward.
mypy: no issues in
flows/llm_flows/tools/_toolset_auth.py.pre-commitpasses.Manual End-to-End (E2E) Tests:
N/A: import-time change with no behavior change. The toolset auth path still resolves the prefix
(covered by the flows and auth tests above).
Checklist