From 69283e113792441664bad485df26a8d294dbd7d1 Mon Sep 17 00:00:00 2001 From: Yashwant Bezawada Date: Sun, 16 Nov 2025 12:53:08 -0600 Subject: [PATCH] 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 --- python/semantic_kernel/agents/agent.py | 17 ++++++++++++++--- 1 file changed, 14 insertions(+), 3 deletions(-) diff --git a/python/semantic_kernel/agents/agent.py b/python/semantic_kernel/agents/agent.py index 31712a7ebfb9..3210dc51de02 100644 --- a/python/semantic_kernel/agents/agent.py +++ b/python/semantic_kernel/agents/agent.py @@ -13,6 +13,7 @@ from pydantic import Field, model_validator from semantic_kernel.agents.channels.agent_channel import AgentChannel +from semantic_kernel.connectors.ai.prompt_execution_settings import PromptExecutionSettings from semantic_kernel.contents.chat_message_content import CMC_ITEM_TYPES, ChatMessageContent from semantic_kernel.contents.streaming_chat_message_content import StreamingChatMessageContent from semantic_kernel.contents.utils.author_role import AuthorRole @@ -998,9 +999,19 @@ def _normalize_spec_fields( if v.get("default") is not None } - # Start with model options - arguments = KernelArguments(**model_options) - # Update with input defaults (only if not already provided by model options) + # Convert model options to execution settings + # Model options (like response_format, temperature, etc.) should be execution settings, + # not regular arguments + if model_options: + # Create PromptExecutionSettings from model options + # The PromptExecutionSettings constructor handles **kwargs by putting them in extension_data + # and then unpacking them to actual fields if they exist + exec_settings = PromptExecutionSettings(**model_options) + arguments = KernelArguments(settings=exec_settings) + else: + arguments = KernelArguments() + + # Add input defaults as regular dict items (not execution settings) for k, v in input_defaults.items(): if k not in arguments: arguments[k] = v