Python: Fix azurefunctions MCP tool invocation to use correct agent #3339
Merged
gavin-aguiar merged 3 commits intomainfrom Jan 22, 2026
Merged
Python: Fix azurefunctions MCP tool invocation to use correct agent #3339gavin-aguiar merged 3 commits intomainfrom
gavin-aguiar merged 3 commits intomainfrom
Conversation
Member
Python Test Coverage Report •
Python Unit Test Overview
|
|||||||||||||||||||||||||||||||||||
Contributor
There was a problem hiding this comment.
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 |
python/packages/azurefunctions/agent_framework_azurefunctions/_app.py
Outdated
Show resolved
Hide resolved
python/packages/azurefunctions/agent_framework_azurefunctions/_app.py
Outdated
Show resolved
Hide resolved
larohra
reviewed
Jan 21, 2026
python/packages/azurefunctions/agent_framework_azurefunctions/_app.py
Outdated
Show resolved
Hide resolved
larohra
approved these changes
Jan 22, 2026
hallvictoria
approved these changes
Jan 22, 2026
arisng
pushed a commit
to arisng/agent-framework
that referenced
this pull request
Feb 2, 2026
…icrosoft#3339) * MCP tool fix for azurefunctions * Moving logic to check for thread id
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.
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