-
Notifications
You must be signed in to change notification settings - Fork 1.1k
Python: Fix azurefunctions MCP tool invocation to use correct agent #3339
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
Python Test Coverage Report •
Python Unit Test Overview
|
|||||||||||||||||||||||||||||||||||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pull request overview
This pull request fixes an issue in the MCP tool invocation flow where the agent entity routing was incorrectly using the agent name embedded in the threadId parameter instead of the agent_name parameter passed to the handler function. The fix ensures that MCP tool invocations always route to the correct agent entity based on the invoked agent, not the agent name potentially stored in the thread ID from a previous conversation.
Changes:
- Modified thread ID parsing logic to extract only the session key from thread_id while always using the agent_name parameter for entity routing
- Added comprehensive test coverage for the scenario where thread_id contains a different agent name than the invoked agent
Reviewed changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated 3 comments.
| File | Description |
|---|---|
| python/packages/azurefunctions/agent_framework_azurefunctions/_app.py | Updated _handle_mcp_tool_invocation to parse thread_id differently - extracting only the key portion while using the agent_name parameter for the entity name |
| python/packages/azurefunctions/tests/test_app.py | Added test case test_handle_mcp_tool_invocation_ignores_agent_name_in_thread_id to verify the fix works correctly when thread_id contains a different agent name |
Motivation and Context
Summary
Fixed an issue for MCP tool invocations to route to the correct agent based on the thread id.
Description
Contribution Checklist