.Net: Fix FunctionChoiceBehavior State Restoration in OllamaPromptExecutionSettings. #9718
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.
Description
This PR addresses a bug in
OllamaPromptExecutionSettings
where theFunctionChoiceBehavior
state was not properly restored during the conversion process fromPromptExecutionSettings
. Specifically, the internal state ofFunctionChoiceBehavior
, including its list of associated functions, was lost during serialization and deserialization.Motivation and Context
Why is this change required?
The lack of proper state restoration led to missing function definitions in HTTP requests when using the Ollama connector, causing failures in scenarios that rely on function calls.
What problem does it solve?
This change ensures that the
FunctionChoiceBehavior
is fully restored when converting execution settings, maintaining the expected behavior for function calls in the Ollama connector.What scenario does it contribute to?
This fix enables consistent and reliable function calling with the Ollama connector, ensuring that defined functions are included in requests and operate as expected.
Related Issues
This change fixes the issue described in the bug report, improving usability and reliability when working with function behaviors in Semantic Kernel integrations.
Contribution Checklist
Fixes #9682