Repository navigation
fix: route authentication responses to requesting sub-agents - #7203
Junyi-Zheng wants to merge 4 commits into
Conversation
|
Thanks for your pull request! It looks like this may be your first contribution to a Google open source project. Before we can look at your pull request, you'll need to sign a Contributor License Agreement (CLA). View this failed invocation of the CLA check for more information. For the most up to date status, view the checks section at the bottom of the pull request. |
Resolve the router import conflict by using flows.llm_flows.tools._functions for call matching and the credential request constant.
Preserve upstream abort-event routing and rewind-aware branch restoration alongside authentication-response routing. Keep both sets of regression tests and cover late authentication replies after cancellation.
|
Thank you for this PR, and for the unusually thorough investigation behind it — the problem statement, the cross-version test matrix, and the regression cases were all genuinely useful, and they shaped how we looked at this area internally. I want to be transparent about why I'm closing it rather than merging. While this PR was in review, the same root cause —
With those in, the If, after re-testing against current Apologies that the overlap wasn't flagged earlier in the review; that's on us. Thanks again for the care you put into this. |
Link to Issue or Description of Change
Related: #7182
Problem: When a chat sub-agent with
disallow_transfer_to_parent=Truerequests credentials, the Runner selects the next agent before appending the
incoming authentication response. History-only routing can therefore send that
response to the root instead of the child that requested it, preventing the
protected tool from resuming.
Solution: Pass the incoming message to the router and resolve credential
responses against outstanding requests in the same session, after applying
rewinds. Use request IDs and persisted node paths to identify the requesting
agent, and require batched responses to belong to one agent and invocation.
Unmatched, already-answered, ambiguous, and ordinary messages retain the existing
routing behavior. Workflow and task-agent routing are preserved.
This is a focused authentication-response routing fix. It does not claim to
resolve every configuration or the original report's entire UI symptom.
Testing Plan
Validated commit:
2028cbd6ff9ad713d02f0985f6a4a1210840a5a5.Base:
665ec9835bee154f6d30ff49fb5125d79ef57e8c.Platform: macOS ARM64. Tests use the repository's
testextra.Unit tests
authentication, resumability on/off, direct/nested children, and memory/SQLite
session storage.
uv lock tox run-parallel -p 2 --parallel-no-spinner \ -x 'testenv.commands=pytest tests/unittests -n 4 --tb=short --junitxml={tox_root}/../adk-7182-investigation/release-validation/{env_name}.xml' \ --result-json ../adk-7182-investigation/release-validation/tox-full.jsonThe checkout ignores
uv.lock, although tox requiresuv sync --locked; thefirst attempt stopped during setup until a local lock was generated. The lock
is included in the validation attachment, not in the code changes. No tests
were deselected or newly marked xfail. Four pytest workers and two concurrent
tox environments only change execution parallelism and reporting.
In each environment, the router/resume files record 61 passed, 1 skipped, 1 xfailed, including 16/16 passing restricted-child authentication regressions. Existing non-strict xpasses are reported separately.
The remaining failure is
test_import_loading.py::test_entry_point_loads_only_allowlisted_packages[agent].Importing
Agentloads authlib and its transitive dependencies outside theexisting allowlist. Running the same test against a
git archiveof theunmodified base, with the same interpreters and installed dependencies,
reproduces the failure. This comparison is limited to the failing import tests;
it is not a claim that the full base suite was rerun.
The first Python 3.13 run selected Anaconda and also failed the
runnerimportcase because it loaded
sitecustomize. A fresh uv-managed Python 3.13 environmentwas used for the final full rerun; both initial and rerun evidence are retained.
Wheel build and clean installation
uv build --out-dir ../adk-7182-investigation/release-validation/dist cd ../adk-7182-investigation/release-validation uv venv --python 3.12 wheel-venv uv pip install --python wheel-venv/bin/python dist/google_adk-2.9.0-py3-none-any.whl uv pip check --python wheel-venv/bin/python wheel-venv/bin/adk --help wheel-venv/bin/python -I ../probe.py --topology transfer_locked --output wheel-runner.jsonBuilt the sdist and wheel successfully. The clean environment contains the
wheel and its declared runtime dependencies;
pip checkreports all 48 installedpackages compatible. Imports resolve to that environment's
site-packages.Both changed production modules in the wheel match the validated Git commit.
The CLI starts successfully.
The installed-wheel Runner reproduction passes 8/8 cases: tool/toolset ×
OIDC/OAuth2 × resumability off/on. Each case completes the protected tool exactly
once, raises no exception, and does not request authentication again.
This deterministic reproduction uses synthetic tokens, not a live identity
provider. The wheel SHA-256 is
80893288ff0af9e16b9a8e9aa418ef71730675aa3f81b7d59f927dec187e1e42.Manual end-to-end tests
Ran the original ADK Web UI against a real local Keycloak 26.7.4 server with a
temporary realm/client/user. A deterministic offline model transfers to the
restricted child; the browser completes OAuth authorization, ADK exchanges the
real authorization code, and the child resumes its protected tool.
All four configurations—tool/toolset authentication × resumability off/on—
completed the Web automatic callback after establishing an SSO session. Each
produced
child completed, one successful tool execution per session, and areal Keycloak userinfo response with HTTP 200 and
preferred_username=routing-user.The first password-login check used a separately controlled tab and a manually
submitted
/runcallback; that assisted run is recorded separately and is notcounted as one of the four automatic Web runs.
The validation attachment's
REPRODUCE.mdincludes the Docker command, agentsetup, browser steps, and expected output. It also includes the Runner probe,
test realm, and sanitized
keycloak-evidence.json; real tokens and authorizationcodes are omitted. No live Gemini model or production identity deployment was
tested.
Additional context
Additional experiments outside the submitted unit suite recorded 62 passed /
6 failed across 68 cases. These include process restart with SQLite, user and
session isolation, delayed callbacks, sequential/concurrent duplicate callbacks,
same-named children, and failed-authentication retries.
Two limitations remain: simultaneous duplicate callbacks can execute a tool more
than once with in-memory resumable sessions, and some toolset authentication
retries after denial or a state mismatch request authentication again. An
upstream-router comparison with ordinary transferable children also reproduces
both behaviors (16 passed / 8 failed across 24 cases). That comparison changes
the transfer restrictions to avoid the original routing defect; it is not an
identical restricted-child baseline. This PR does not provide concurrent
exactly-once execution or repair those retry paths.
Authentication propagation through
AgentToolis a separate issue and remainsout of scope. The base already contains upstream commit
2c61b844; this patchdoes not require an unpublished downstream dependency.
Checklist
validation-evidence.zip