Skip to content

Python: FIX: honor overwrite=False for default execution settings in PromptTemplateConfig - #14586

Merged
Eduard van Valkenburg (eavanvalkenburg) merged 5 commits into
microsoft:mainfrom
inchang-ing:fix/prompt-template-config-default-execution-settings
Oct 27, 2026
Merged

Eduard van Valkenburg (eavanvalkenburg) merged 5 commits into
microsoft:mainfrom
inchang-ing:fix/prompt-template-config-default-execution-settings

Conversation

@inchang-ing

Copy link
Copy Markdown
Contributor

Why

PromptTemplateConfig.add_execution_settings(settings, overwrite=False) still replaced the existing entry when settings.service_id is None (the common case). Fixes #14582.

Root cause

The membership check used settings.service_id (None) while the entry is stored under settings.service_id or DEFAULT_SERVICE_NAME ("default"). None in self.execution_settings is always False, so overwrite=False never protected the default entry. The "already exist" warning was also logged after every successful add, and never when an add was actually refused.

Fix

Use the same resolved key (settings.service_id or DEFAULT_SERVICE_NAME) for both the membership check and the store, and emit the warning only on the refused path.

Tests

  • test_add_execution_settings_no_overwrite_default_service: overwrite=False keeps the original default settings.
  • test_add_execution_settings_warning_only_when_refused: warning appears only when an add is refused, not on a fresh add.

Both fail on the unpatched code and pass with the fix; the 18 pre-existing tests in the file still pass.

…mplateConfig

add_execution_settings() checked membership with settings.service_id (None for the
default service) but stored under settings.service_id or DEFAULT_SERVICE_NAME. The
mismatch meant the None key never matched, so overwrite=False never protected the
"default" entry. Use the same resolved key for both the check and the store, and
emit the "already exist" warning only when the add is actually refused.

fixes microsoft#14582
Copilot AI balanced review requested due to automatic review settings October 13, 2026 16:11
@inchang-ing
inchang-ing requested a review from a team as a code owner October 13, 2026 16:11
@inchang-ing

Copy link
Copy Markdown
Contributor Author

@microsoft-github-policy-service agree

@semantic-kernel-automation semantic-kernel-automation Bot added the python Pull requests for the Python Semantic Kernel label Oct 13, 2026
@github-actions github-actions Bot changed the title FIX: honor overwrite=False for default execution settings in PromptTemplateConfig Python: FIX: honor overwrite=False for default execution settings in PromptTemplateConfig Oct 13, 2026

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.

🟢 Approval recommended

The implementation and tests correctly address the reported defect; only a minor comment-language issue remains.

1 open finding
What changed in this PR

Fixes default execution settings being overwritten despite overwrite=False.

Changes:

  • Resolves the effective service key before checking and storing settings.
  • Logs warnings only when an addition is refused.
  • Adds regression tests for default settings and warning behavior.
File Description
python/​semantic_kernel/​prompt_template/​prompt_template_config.py Corrects overwrite handling and warning placement.
python/​tests/​unit/​prompt_template/​test_prompt_templates.py Adds regression coverage.

🧠 Review effort: Balanced


💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.

Comment thread python/semantic_kernel/prompt_template/prompt_template_config.py Outdated
Keep code comments under python/semantic_kernel English-only so the maintenance context stays accessible to every contributor.
auto-merge was automatically disabled October 26, 2026 19:07

Head branch was pushed to by a user without write access

@inchang-ing
inchang-ing deployed to github-app-auth October 26, 2026 19:07 — with GitHub Actions Active
Merged via the queue into microsoft:main with commit 9a70006 Oct 27, 2026
33 checks passed

This branch was successfully deployed

1 active deployment
github-app-auth — 8db227d1 Deployed Oct 26, 2026 by inchang-ing via add_label #29457
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

python Pull requests for the Python Semantic Kernel

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Python: Bug: PromptTemplateConfig.add_execution_settings(overwrite=False) overwrites the default service settings

3 participants