Repository navigation
fix(google_genai): cancelling one MCP caller no longer cancels the others - #582
Merged
brianstrauch merged 1 commit intoNov 16, 2026
Conversation
…hers session() awaited the shared connect future directly, so cancelling one caller cancelled that future and every other caller waiting on it. Shield the wait. Only the cancelled caller stops.
brianstrauch
enabled auto-merge (squash)
November 16, 2026 18:49
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.
Fixes #571
Cause. Activities that open the same MCP server at the same time share one
_ConnectionRecordand wait on its_readyfuture.session()awaited that future directly. Cancelling one caller also cancels the future, so every other caller waiting on it receivesCancelledError, and the connect itself is cancelled.Fix.
session()now waits withasyncio.shield(self._ready). The cancelled caller still stops, andget_connectionstill releases that caller's in-flight hold. The shared future, the owner task that is opening the session, and the other callers continue. Those callers receive the session once the factory finishes.Test.
test_cancelling_one_mcp_caller_leaves_the_other_waitingpauses the session factory on an event, starts twoget_connectioncallers, cancels the first, then releases the factory. Against the current main implementation the shared future is cancelled and the test fails. With this change the second caller receives the session. The surrounding MCP unit tests in the same file also pass.This change was prepared with the help of an AI coding assistant.