From 6f43a8b80c7609175a035b410aae1927656e00bb Mon Sep 17 00:00:00 2001 From: Jack Gerrits Date: Fri, 5 Apr 2024 10:06:11 -0400 Subject: [PATCH] Copy llm config to avoid external changes (#2290) --- autogen/agentchat/conversable_agent.py | 3 +++ 1 file changed, 3 insertions(+) diff --git a/autogen/agentchat/conversable_agent.py b/autogen/agentchat/conversable_agent.py index a2f021f5781c..a49f8a5b43b9 100644 --- a/autogen/agentchat/conversable_agent.py +++ b/autogen/agentchat/conversable_agent.py @@ -138,6 +138,9 @@ def __init__( if is_termination_msg is not None else (lambda x: content_str(x.get("content")) == "TERMINATE") ) + # Take a copy to avoid modifying the given dict + if isinstance(llm_config, dict): + llm_config = copy.deepcopy(llm_config) self._validate_llm_config(llm_config)