fix: resolve Semantic Kernel tool call names#7786
Open
meaqua9420 wants to merge 1 commit into
Open
Conversation
Author
|
@microsoft-github-policy-service agree |
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.
Why are these changes needed?
Semantic Kernel / Bedrock can return tool calls with the AutoGen tool plugin prefix or with hyphenated function names, for example
autogen-tools_get_weatherorget-weather. AutoGen workbenches register the original tool names, such asget_weather, so those calls fail exact-name lookup even though the requested tool exists.This changes
SKChatCompletionAdapterto resolve returned function-call names against the tools passed to the request. Exact matches still win first; then the adapter handles the AutoGen-managed plugin prefix and hyphen/underscore normalization only when it maps unambiguously to a registered tool. Calls from external kernel plugins keep the existingplugin-functionname when there is no matching AutoGen tool.Related issue number
Fixes #5439
Checks
Local validation:
uv run --extra semantic-kernel-core pytest packages/autogen-ext/tests/models/test_sk_chat_completion_adapter.py -quv run ruff format --check packages/autogen-ext/src/autogen_ext/models/semantic_kernel/_sk_chat_completion_adapter.py packages/autogen-ext/tests/models/test_sk_chat_completion_adapter.pyuv run ruff check packages/autogen-ext/src/autogen_ext/models/semantic_kernel/_sk_chat_completion_adapter.py packages/autogen-ext/tests/models/test_sk_chat_completion_adapter.pyuv run pyright packages/autogen-ext/src/autogen_ext/models/semantic_kernel/_sk_chat_completion_adapter.py packages/autogen-ext/tests/models/test_sk_chat_completion_adapter.pygit diff --check origin/main...HEAD