Python: How can I create Deterministic AI Agents?
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!
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.
Hi @sashanknjs if it helps can try experimenting this settings
if you set the top k=1 and keeping temperature constant you might endup getting similar response