adk-python icon indicating copy to clipboard operation
adk-python copied to clipboard

getting asyncio.exceptions.CancelledError when running pytest evalation for agent which uses mcptoolset

Open VandanaJn opened this issue 1 year ago • 3 comments

My agent is using mcptoolset, and my test looks like this @pytest.mark.asyncio async def test_with_simple_trajectory(): """Test the agent's basic ability via a session file."""

await AgentEvaluator.evaluate(
    agent_module="repo_navigator",
    eval_dataset_file_path_or_dir="tests/integration/test_files/simple_trajectory/simple_tractory_test.json",
    print_detailed_results=True, 
)

it fails with _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _

fut = <Task cancelled name='Task-35' coro=<ClientSession.list_tools() done, defined at C:\learning\Repo-Navigator-AI.venv\Lib\site-packages\mcp\client\session.py:473>> loop =

async def _cancel_and_wait(fut, loop):
    """Cancel the *fut* future or task and wait until it completes."""

    waiter = loop.create_future()
    cb = functools.partial(_release_waiter, waiter)
    fut.add_done_callback(cb)

    try:
        fut.cancel()
        # We cannot wait on *fut* directly to make
        # sure _cancel_and_wait itself is reliably cancellable.
      await waiter

E asyncio.exceptions.CancelledError: Cancelled via cancel scope 28719010b10 by <Task pending name='Task-22' coro=<McpToolset.close() running at C:\learning\Repo-Navigator-AI.venv\Lib\site-packages\google\adk\tools\mcp_tool\mcp_toolset.py:217> cb=[_release_waiter(<Future pendi...ask_wakeup()]>)() at C:\Users\vanda\AppData\Local\Programs\Python\Python311\Lib\asyncio\tasks.py:431]>

C:\Users\vanda\AppData\Local\Programs\Python\Python311\Lib\asyncio\tasks.py:562: CancelledError, is this a known issue?

VandanaJn avatar Nov 27 '25 22:11 VandanaJn

This is not a known issue.

Can you please provide following details:

  • which ADK version are you running?
  • Does the issue happen every time or is it flaky?
  • Can you provide full stack trace (excluding calls to your code)?

ankursharmas avatar Dec 02 '25 01:12 ankursharmas

This issue has been automatically marked as stale because it has not had recent activity for 7 days after a maintainer requested clarification. It will be closed if no further activity occurs within 7 days.

adk-bot avatar Dec 10 '25 05:12 adk-bot

This has been automatically closed because it has been marked as stale for over 7 days.

adk-bot avatar Dec 18 '25 23:12 adk-bot