Commit 775b8fc
authored
Fix YAML agent ignoring model.options execution settings (#13365)
## Summary
Fixes #13349
When loading agents from YAML files using
`AgentRegistry.create_from_file()` or `create_from_yaml()`, the
`model.options` field (containing settings like `response_format`,
`temperature`, etc.) were being added as regular `KernelArguments` dict
items instead of being placed in the `execution_settings` property. This
caused AI service calls to ignore these critical settings.
## Root Cause
In `_normalize_spec_fields()` method in
`python/semantic_kernel/agents/agent.py`, model options were being
passed to `KernelArguments` constructor as `**kwargs`:
```python
# OLD (buggy) CODE
arguments = KernelArguments(**model_options)
```
This made them regular dict items, but execution settings need to be in
the `execution_settings` property to be passed to AI services.
## Changes
Modified `_normalize_spec_fields()` in
`python/semantic_kernel/agents/agent.py`:
- Added import for `PromptExecutionSettings`
- Convert model.options to `PromptExecutionSettings` object before
creating `KernelArguments`
- Model options now correctly placed in `execution_settings` property
- Input defaults continue to be added as regular dict items (correct
behavior)
## Testing
- ✅ Created custom test verifying model.options are now in
execution_settings
- ✅ All 30 existing unit tests in `tests/unit/agents/test_agent.py` pass
- ✅ No breaking changes introduced
- ✅ Verified execution_settings passed programmatically still work
correctly
## Example
YAML file:
```yaml
type: chat_completion_agent
name: TestAgent
description: Test agent
instructions: You are a test agent
model:
options:
response_format: structured_output
temperature: 0.7
```
**Before this fix:**
- `response_format` was in dict items (wrong location)
- AI service calls ignored it
**After this fix:**
- `response_format` is in `execution_settings.extension_data`
- AI service calls receive it properly1 parent 6888aa6 commit 775b8fc
1 file changed
+14
-3
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
13 | 13 | | |
14 | 14 | | |
15 | 15 | | |
| 16 | + | |
16 | 17 | | |
17 | 18 | | |
18 | 19 | | |
| |||
998 | 999 | | |
999 | 1000 | | |
1000 | 1001 | | |
1001 | | - | |
1002 | | - | |
1003 | | - | |
| 1002 | + | |
| 1003 | + | |
| 1004 | + | |
| 1005 | + | |
| 1006 | + | |
| 1007 | + | |
| 1008 | + | |
| 1009 | + | |
| 1010 | + | |
| 1011 | + | |
| 1012 | + | |
| 1013 | + | |
| 1014 | + | |
1004 | 1015 | | |
1005 | 1016 | | |
1006 | 1017 | | |
| |||
0 commit comments