Skip to content

Commit 69283e1

Browse files
Fix YAML agent ignoring model.options execution settings
Fixes #13349 When loading agents from YAML files, model.options (like response_format, temperature, etc.) were being added as regular KernelArguments dict items instead of being placed in execution_settings. This caused AI service calls to ignore these settings. Changes: - Modified _normalize_spec_fields() in agent.py to convert model.options to PromptExecutionSettings before creating KernelArguments - Model options now correctly placed in execution_settings property - Input defaults continue to be added as regular dict items (correct) Testing: - Verified with custom test showing model.options now in execution_settings - All 30 existing unit tests in tests/unit/agents/test_agent.py pass - No breaking changes introduced
1 parent de20575 commit 69283e1

File tree

1 file changed

+14
-3
lines changed

1 file changed

+14
-3
lines changed

python/semantic_kernel/agents/agent.py

Lines changed: 14 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@
1313
from pydantic import Field, model_validator
1414

1515
from semantic_kernel.agents.channels.agent_channel import AgentChannel
16+
from semantic_kernel.connectors.ai.prompt_execution_settings import PromptExecutionSettings
1617
from semantic_kernel.contents.chat_message_content import CMC_ITEM_TYPES, ChatMessageContent
1718
from semantic_kernel.contents.streaming_chat_message_content import StreamingChatMessageContent
1819
from semantic_kernel.contents.utils.author_role import AuthorRole
@@ -998,9 +999,19 @@ def _normalize_spec_fields(
998999
if v.get("default") is not None
9991000
}
10001001

1001-
# Start with model options
1002-
arguments = KernelArguments(**model_options)
1003-
# Update with input defaults (only if not already provided by model options)
1002+
# Convert model options to execution settings
1003+
# Model options (like response_format, temperature, etc.) should be execution settings,
1004+
# not regular arguments
1005+
if model_options:
1006+
# Create PromptExecutionSettings from model options
1007+
# The PromptExecutionSettings constructor handles **kwargs by putting them in extension_data
1008+
# and then unpacking them to actual fields if they exist
1009+
exec_settings = PromptExecutionSettings(**model_options)
1010+
arguments = KernelArguments(settings=exec_settings)
1011+
else:
1012+
arguments = KernelArguments()
1013+
1014+
# Add input defaults as regular dict items (not execution settings)
10041015
for k, v in input_defaults.items():
10051016
if k not in arguments:
10061017
arguments[k] = v

0 commit comments

Comments
 (0)