Repository navigation
fix(flows): resolve toolset credentials before resuming a paused call - #7941
Open
AtulJoshi1206 wants to merge 1 commit into
Open
AtulJoshi1206 wants to merge 1 commit into
AtulJoshi1206 wants to merge 1 commit into
Conversation
The request_confirmation and auth request processors list the agent's tools to re-run a call that was waiting on the user. They run before the toolset_auth processor, which is what puts each authenticated toolset's credential for this invocation into credential_by_key. So when they list an McpToolset that has an auth_scheme, the toolset finds no credential and connects without one. That only worked while the toolset still cached the paused invocation's tool listing. Any other invocation listing the same toolset replaces that single cached entry, and a restarted process or another instance has no entry at all. Then an authenticated server refuses the anonymous connection, the toolset is dropped, and an approved call fails the invocation with "Tool '<name>' is not registered". A call resumed after tool-level auth is answered with "no tool with that name is available" instead of being run. Factor the credential resolution out of resolve_toolset_auth into resolve_toolset_credentials, which resolves what is available without asking the user for anything. Call it from both resume processors before they list tools. Nothing changes for the model request path.
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.
Please ensure you have read the contribution guide before creating a pull request.
Link to Issue or Description of Change
No existing issue; described below following the bug-report structure.
Describe the Bug:
When a paused tool call is resumed (an approved confirmation, or a tool-level auth answer), the
request_confirmationandauthrequest processors list the agent's tools themselves so they can re-run the call. Both run before thetoolset_authprocessor, and that processor is the only place that puts an authenticated toolset's credential for the invocation intocredential_by_key.So an
McpToolsetwith anauth_scheme, or any toolset usingget_auth_config(), lists its tools without its credential. That breaks the contract inBaseToolset.get_auth_configand in the toolset guide ("ADK resolves the credential before it callsget_tools"). It has only worked while the toolset still cached the paused invocation's listing.Impact:
Human-in-the-loop approval on an authenticated MCP server fails whenever that cache doesn't hold the paused invocation's listing. That happens:
So it happens in pretty much any real deployment. On a single-session dev setup it works, which is probably why nobody noticed.
Observed Behavior:
ValueError: Tool 'send_email' is not registered.The email is never sent, and sending the approval again fails the same way.Invoking export_report() failed as no tool with that name is available. The tools you can call are: none., and the tool never runs.Expected Behavior:
The resumed call lists the toolset with the user's credential and runs, the same as on the first turn.
Solution:
I moved the credential loop out of
resolve_toolset_authintoresolve_toolset_credentials. It fillscredential_by_keywith whatever is available and returns the toolsets that still need auth, without asking the user for anything.resolve_toolset_authbehaves exactly as before, so nothing changes on the normal model-request path.I looked at the obvious alternatives:
request_confirmationhas to run beforecontents, and the auth processor has to store the response before toolset auth reads it.Testing Plan
Unit Tests:
New tests:
TestMcpToolsetCredentialOnResumeruns a real in-process MCP server throughRunnerandMcpToolset; the server refuses connections without the bearer token. It covers an approval served by another process, and an approval after another session's turn.TestToolsetCredentialOnAuthResumecovers a toolset that uses the documentedget_auth_configpattern, whose tool asks for its own credential.test_resolving_credentials_requests_nothingcovers the new helper.On
main, all 4 fail with the errors above. With the fix, all 4 pass.pyinkandisortare clean, and mypy reports nothing new.Manual End-to-End (E2E) Tests:
Not run against a live MCP server. The runner tests drive the full flow with an in-process server.
Checklist
Additional context
#7909 fixes a different MCP auth issue (
credential_keynot reaching the tools). The two are independent; both just append totest_mcp_toolset_auth.py.🤖 Generated with Claude Code