From 76004bd737da83207fa689d92947771787b1d004 Mon Sep 17 00:00:00 2001 From: CI-DEV <154627941+IlumCI@users.noreply.github.com> Date: Tue, 7 Oct 2025 20:14:24 +0300 Subject: [PATCH] Update agent.py --- swarms/structs/agent.py | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/swarms/structs/agent.py b/swarms/structs/agent.py index 4b41651f..355265ca 100644 --- a/swarms/structs/agent.py +++ b/swarms/structs/agent.py @@ -2406,12 +2406,14 @@ class Agent: Dict[str, Any]: A dictionary representation of the class attributes. """ - # Remove the llm object from the dictionary - self.__dict__.pop("llm", None) + # Create a copy of the dict to avoid mutating the original object + # Remove the llm object from the copy since it's not serializable + dict_copy = self.__dict__.copy() + dict_copy.pop("llm", None) return { attr_name: self._serialize_attr(attr_name, attr_value) - for attr_name, attr_value in self.__dict__.items() + for attr_name, attr_value in dict_copy.items() } def to_json(self, indent: int = 4, *args, **kwargs):