Repository navigation
Commit 9a70006
authored
Python: FIX: honor overwrite=False for default execution settings in PromptTemplateConfig (#14586)
## 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.
---------
Co-authored-by: inchang-ing <[email protected]>1 parent b5b526d commit 9a70006
2 files changed
Lines changed: 34 additions & 3 deletions
File tree
- python
- semantic_kernel/prompt_template
- tests/unit/prompt_template
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
71 | 71 | | |
72 | 72 | | |
73 | 73 | | |
74 | | - | |
| 74 | + | |
| 75 | + | |
| 76 | + | |
| 77 | + | |
| 78 | + | |
| 79 | + | |
75 | 80 | | |
76 | | - | |
77 | | - | |
| 81 | + | |
78 | 82 | | |
79 | 83 | | |
80 | 84 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
2 | 2 | | |
3 | 3 | | |
4 | 4 | | |
| 5 | + | |
5 | 6 | | |
6 | 7 | | |
7 | 8 | | |
| |||
72 | 73 | | |
73 | 74 | | |
74 | 75 | | |
| 76 | + | |
| 77 | + | |
| 78 | + | |
| 79 | + | |
| 80 | + | |
| 81 | + | |
| 82 | + | |
| 83 | + | |
| 84 | + | |
| 85 | + | |
| 86 | + | |
| 87 | + | |
| 88 | + | |
| 89 | + | |
| 90 | + | |
| 91 | + | |
| 92 | + | |
| 93 | + | |
| 94 | + | |
| 95 | + | |
| 96 | + | |
| 97 | + | |
| 98 | + | |
| 99 | + | |
| 100 | + | |
| 101 | + | |
75 | 102 | | |
76 | 103 | | |
77 | 104 | | |
| |||
0 commit comments