Skip to content

Fix McpWorkbench tool call cancellation (AttributeError) - #8280

Open
Hardik K (hardikkaurani) wants to merge 2 commits into
microsoft:mainfrom
hardikkaurani:fix/mcp-cancellation-8265
Open

Hardik K (hardikkaurani) wants to merge 2 commits into
microsoft:mainfrom
hardikkaurani:fix/mcp-cancellation-8265

Conversation

@hardikkaurani

@hardikkaurani Hardik K (hardikkaurani) commented Sep 24, 2026 •

Copy link
Copy Markdown

Summary

This PR fixes a cancellation bug in the MCP Workbench tool execution. It wraps the raw coroutine in asyncio.ensure_future() to safely handle cancellation exceptions.

Problem

When a tool execution is cancelled in the MCP Workbench, an AttributeError is raised because the raw coroutine cannot be properly cancelled without being wrapped in a task.

Root Cause

The McpWorkbench.call_tool method awaits a raw coroutine directly instead of ensuring it is a proper asyncio Task, preventing safe cancellation propagation.

Changes

  • Wraps the tool call coroutine in asyncio.ensure_future() in McpWorkbench.call_tool.
  • Gracefully catches asyncio.CancelledError.

Tests

Regression coverage is included for the affected behavior.

Why This Is Not a Duplicate

This PR addresses a different issue from #8284.

Therefore, the two PRs address independent problems and this change does not supersede or duplicate #8284.

Scope

This change is limited to McpWorkbench.call_tool in autogen-ext and does not alter other tool execution paths.

Copilot AI lite review requested due to automatic review settings September 24, 2026 19:04

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copilot was unable to review this pull request because the user who requested the review has reached their quota limit.

@hardikkaurani

Copy link
Copy Markdown
Author

@microsoft-github-policy-service agree

@hardikkaurani

Copy link
Copy Markdown
Author

Eric Zhu (@ekzhu) Victor Dibia (@victordibia) The fix for the MCP Workbench tool cancellation AttributeError is complete and ready for review. It properly wraps the coroutine in \�syncio.ensure_future()\ so \cancellation_token.link_future()\ can safely manage its state. Tests are included and CLA/basic checks pass. Please take a look when you have time! Thanks.

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants