Fix YAML agent ignoring model.options execution settings #13365
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.
Summary
Fixes #13349
When loading agents from YAML files using
AgentRegistry.create_from_file()orcreate_from_yaml(), themodel.optionsfield (containing settings likeresponse_format,temperature, etc.) were being added as regularKernelArgumentsdict items instead of being placed in theexecution_settingsproperty. This caused AI service calls to ignore these critical settings.Root Cause
In
_normalize_spec_fields()method inpython/semantic_kernel/agents/agent.py, model options were being passed toKernelArgumentsconstructor as**kwargs:This made them regular dict items, but execution settings need to be in the
execution_settingsproperty to be passed to AI services.Changes
Modified
_normalize_spec_fields()inpython/semantic_kernel/agents/agent.py:PromptExecutionSettingsPromptExecutionSettingsobject before creatingKernelArgumentsexecution_settingspropertyTesting
tests/unit/agents/test_agent.pypassExample
YAML file:
Before this fix:
response_formatwas in dict items (wrong location)After this fix:
response_formatis inexecution_settings.extension_data