Skip to content

[Bug] google_genai: cancelling one MCP caller also cancels other callers #571

Closed

Description

@campoy

What are you really trying to do?

Cancel one Activity without cancelling other Activities waiting for the same MCP connection.

Describe the bug

Activities share a connection attempt when they call the same MCP server at the same time. Each caller waits on the same _ready future.

If one caller is cancelled, asyncio also cancels that shared future. The other callers then receive CancelledError, even though nobody cancelled them.

How did you hit this issue?

Found during review of #531. We left this for a follow-up with its own concurrency tests.

Minimal Reproduction

The failure sequence is:

  1. Start opening an MCP connection and pause before it is ready.
  2. Let callers A and B wait for that connection.
  3. Cancel A.
  4. B also receives CancelledError.

B should keep waiting and receive the connection once it is ready.

Environment/Versions

Package: temporalio-google-genai.

Affected code: _ConnectionRecord.session() in _mcp.py. This bug predates #531.

Additional context

Use asyncio.shield() when waiting on shared readiness. Cancelling a caller should still cancel that caller, while leaving the connection attempt and other callers alone.

Add a test that pauses the connection with an event, cancels one of two callers, then lets the connection finish. The other caller should succeed.

Activity

  1. added
    bug
    on Nov 16, 2026
  2. added a commit that references this issue on Nov 16, 2026
    799b7a3
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    bug

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions