semantic-kernel icon indicating copy to clipboard operation
semantic-kernel copied to clipboard

Python: How can I create Deterministic AI Agents?

Open sashanknjs opened this issue 5 months ago • 2 comments

Hi,

I am developing an enterprise application where I need the AI agents (AzureAIAgent) to be deterministic (produce exactly same response to the same prompt and instruction) over multiple runs. From previous discussions, I understood that the 'Seed' parameter can help get close responses although it does not guarantee the same. I have seen that the semantic kernel supports this parameter with the "OpenAIPromptExecutionSettings" and "AzureChatPromptExecutionSettings" classes, however, if I understood correctly, it is only defined for chat completion models but not for the "AzureAIAgent" class. Is there a way to apply this parameter for my agents, or is there any other way to make my agents as deterministic as possible?

Thanks in advance!

sashanknjs avatar Sep 22 '25 13:09 sashanknjs

Hi @sashanknjs, the short answer: you cannot make OpenAI or Azure OpenAI models perfectly deterministic. Even with a fixed seed and temperature set to 0.0, vendors explicitly state that identical outputs are not guaranteed due to backend variability and model updates. Microsoft documents this for Azure OpenAI’s "reproducible output" feature; seed improves repeatability but does not guarantee identical responses on every call.

See the following Azure docs link, especially around the "Important" callout where "determinism isn't guaranteed."

To take advantage of this, you can use a ChatCompletionAgent with the Azure OpenAI service.

moonbox3 avatar Sep 26 '25 03:09 moonbox3

Hi @sashanknjs if it helps can try experimenting this settings

Image

if you set the top k=1 and keeping temperature constant you might endup getting similar response

MokshithPosa avatar Oct 24 '25 03:10 MokshithPosa