Skip to content

Conversation

@yashwantbezawada
Copy link

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:

# 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:

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 properly

Fixes microsoft#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
@yashwantbezawada yashwantbezawada requested a review from a team as a code owner November 16, 2025 18:53
@yashwantbezawada
Copy link
Author

@microsoft-github-policy-service agree

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Python: Bug: Agent initialised from YAML file does not register the response_format and always responds in free text

1 participant