Repository navigation
Conversation
…lecting an AI service
DZH166
temporarily deployed
to
github-app-auth
November 20, 2026 16:50 — with
GitHub Actions
Inactive
Contributor
There was a problem hiding this comment.
🟢 Approval recommended
No active review issues were identified in the change addressing stale service selection when reusing KernelArguments.
No open issues 🎉
What changed in this PR
Fixes Python AI service selection so reusing KernelArguments does not select a service left over from a previous function call.
Changes:
- Copies the caller’s execution-settings mapping before merging function settings, preserving existing selection precedence.
- Adds a regression test verifying that sequential selections choose the correct services and leave caller-owned mappings unchanged.
| File | Description |
|---|---|
python/tests/unit/services/test_ai_service_selector.py |
Tests sequential service selection and caller-settings isolation. |
python/semantic_kernel/services/ai_service_selector.py |
Copies the settings mapping before merging function defaults. |
Review effort: Balanced
This branch was previously deployed
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.
Problem
AIServiceSelector.select_ai_service()seeds its working dict from the caller'sKernelArguments.execution_settingsand then writes the function's ownprompt_execution_settingsinto that same object:KernelArgumentskeeps the dict it was given by reference, so the caller's object is mutated. Because the id lookup iterates the merged dict in insertion order, a later selection with the same arguments finds the previous function's service id first and resolves the wrong service/settings - silently.Fix
Work on a copy of the caller's settings so selection never writes back into
KernelArguments.Tests
tests/unit/services/test_ai_service_selector.py(new case; the existing selector/content suites stay green):