🐫 CAMEL: The first and the best multi-agent framework. Finding the Scaling Law of Agents. https://www.camel-ai.org
Python agentai-societiesartificial-intelligencecommunicative-aicooperative-aideep-learninglarge-language-modelsmulti-agent-systemsnatural-language-processing
fix: hot fix clone bug
Wendong95d1f1739205
diff --git a/.github/ISSUE_TEMPLATE/bug_report.yml b/.github/ISSUE_TEMPLATE/bug_report.ymlindex 0b2220972..6f67d1c42 100644--- a/.github/ISSUE_TEMPLATE/bug_report.yml+++ b/.github/ISSUE_TEMPLATE/bug_report.yml@@ -26,7 +26,7 @@ body:attributes:label: What version of camel are you using?description: Run command `python3 -c 'print(__import__("camel").__version__)'` in your shell and paste the output here.- placeholder: E.g., 0.2.69a3+ placeholder: E.g., 0.2.69a4validations:required: truediff --git a/camel/__init__.py b/camel/__init__.pyindex 3d9963505..392413845 100644--- a/camel/__init__.py+++ b/camel/__init__.py@@ -14,7 +14,7 @@from camel.logger import disable_logging, enable_logging, set_log_level-__version__ = '0.2.69a3'+__version__ = '0.2.69a4'__all__ = ['__version__',diff --git a/camel/agents/chat_agent.py b/camel/agents/chat_agent.pyindex e7f7710aa..3aacae9c7 100644--- a/camel/agents/chat_agent.py+++ b/camel/agents/chat_agent.py@@ -1904,36 +1904,12 @@ class ChatAgent(BaseAgent):ChatAgent: A new instance of :obj:`ChatAgent` with the sameconfiguration."""- import copy-# Create a new instance with the same configuration# If with_memory is True, set system_message to None# If with_memory is False, use the original system message# To avoid duplicated system memory.system_message = None if with_memory else self._original_system_message- # Create deep copies of tools to avoid shared state- cloned_tools: List[Union[FunctionTool, Callable]] = []- for tool in self._internal_tools.values():- # Create a new FunctionTool instance to avoid sharing state- cloned_tool = copy.deepcopy(tool)- cloned_tools.append(cloned_tool)-- # Create deep copies of external tool schemas- cloned_external_tools: List[- Union[FunctionTool, Callable, Dict[str, Any]]- ] = []- for schema in self._external_tool_schemas.values():- cloned_schema = copy.deepcopy(schema)- cloned_external_tools.append(cloned_schema)-- # Create deep copies of response terminators to avoid shared state- cloned_terminators: List[ResponseTerminator] = []- if self.response_terminators:- for terminator in self.response_terminators:- cloned_terminator = copy.deepcopy(terminator)- cloned_terminators.append(cloned_terminator)-new_agent = ChatAgent(system_message=system_message,model=self.model_backend.models, # Pass the existing model_backend@@ -1943,9 +1919,11 @@ class ChatAgent(BaseAgent):self.memory.get_context_creator(), "token_limit", None),output_language=self._output_language,- tools=cloned_tools,- external_tools=cloned_external_tools,- response_terminators=cloned_terminators,+ tools=[tool.func for tool in self._internal_tools.values()],+ external_tools=[+ schema for schema in self._external_tool_schemas.values()+ ],+ response_terminators=self.response_terminators,scheduling_strategy=self.model_backend.scheduling_strategy.__name__,max_iteration=self.max_iteration,stop_event=self.stop_event,diff --git a/camel/societies/workforce/single_agent_worker.py b/camel/societies/workforce/single_agent_worker.pyindex 2b4d3cd12..6ce56eda9 100644--- a/camel/societies/workforce/single_agent_worker.py+++ b/camel/societies/workforce/single_agent_worker.py@@ -284,6 +284,13 @@ class SingleAgentWorker(Worker):response = await worker_agent.astep(prompt, response_format=TaskResult)++ # Get token usage from the response+ usage_info = response.info.get("usage") or response.info.get(+ "token_usage"+ )+ total_tokens = usage_info.get("total_tokens", 0)+except Exception as e:print(f"{Fore.RED}Error processing task {task.id}: "@@ -294,13 +301,6 @@ class SingleAgentWorker(Worker):# Return agent to pool or let it be garbage collectedawait self._return_worker_agent(worker_agent)- # Get actual token usage from the agent that processed this task- try:- _, total_token_count = worker_agent.memory.get_context()- except Exception:- # Fallback if memory context unavailable- total_token_count = 0-# Populate additional_info with worker attempt detailsif task.additional_info is None:task.additional_info = {}@@ -321,7 +321,7 @@ class SingleAgentWorker(Worker):f"to process task {task.content}","response_content": response.msg.content,"tool_calls": response.info.get("tool_calls"),- "total_token_count": total_token_count,+ "total_tokens": total_tokens,}# Store the worker attempt in additional_info@@ -330,9 +330,7 @@ class SingleAgentWorker(Worker):task.additional_info["worker_attempts"].append(worker_attempt_details)# Store the actual token usage for this specific task- task.additional_info["token_usage"] = {- "total_tokens": total_token_count- }+ task.additional_info["token_usage"] = {"total_tokens": total_tokens}print(f"======\n{Fore.GREEN}Reply from {self}:{Fore.RESET}")diff --git a/docs/conf.py b/docs/conf.pyindex ef9ef3157..6b6884e69 100644--- a/docs/conf.py+++ b/docs/conf.py@@ -27,7 +27,7 @@ sys.path.insert(0, os.path.abspath('..'))project = 'CAMEL'copyright = '2024, CAMEL-AI.org'author = 'CAMEL-AI.org'-release = '0.2.69a3'+release = '0.2.69a4'html_favicon = ('https://raw.githubusercontent.com/camel-ai/camel/master/misc/favicon.png'diff --git a/pyproject.toml b/pyproject.tomlindex 498a9a4e9..33c1af026 100644--- a/pyproject.toml+++ b/pyproject.toml@@ -4,7 +4,7 @@ build-backend = "hatchling.build"[project]name = "camel-ai"-version = "0.2.69a3"+version = "0.2.69a4"description = "Communicative Agents for AI Society Study"authors = [{ name = "CAMEL-AI.org" }]requires-python = ">=3.10,<3.13"diff --git a/uv.lock b/uv.lockindex 188c501e8..1da2a0577 100644--- a/uv.lock+++ b/uv.lock@@ -560,7 +560,7 @@ wheels = [[[package]]name = "camel-ai"-version = "0.2.69a3"+version = "0.2.69a4"source = { editable = "." }dependencies = [{ name = "colorama" },@@ -5611,14 +5611,14 @@ wheels = [[[package]]name = "pypdf"-version = "5.6.0"+version = "5.6.1"source = { registry = "https://pypi.org/simple" }dependencies = [{ name = "typing-extensions", marker = "python_full_version < '3.11'" },]-sdist = { url = "https://files.pythonhosted.org/packages/40/46/67de1d7a65412aa1c896e6b280829b70b57d203fadae6859b690006b8e0a/pypdf-5.6.0.tar.gz", hash = "sha256:a4b6538b77fc796622000db7127e4e58039ec5e6afd292f8e9bf42e2e985a749", size = 5023749 }+sdist = { url = "https://files.pythonhosted.org/packages/f7/8e/9d9346c36bb02fc6d6e5c5412dcc104e422738c3391ef32032bcb7fb183f/pypdf-5.6.1.tar.gz", hash = "sha256:dde36cd67afe3afd733a562a0dd08a3c1dcdf01fe01de13785291319c8a883ff", size = 5025128 }wheels = [- { url = "https://files.pythonhosted.org/packages/71/8b/dc3a72d98c22be7a4cbd664ad14c5a3e6295c2dbdf572865ed61e24b5e38/pypdf-5.6.0-py3-none-any.whl", hash = "sha256:ca6bf446bfb0a2d8d71d6d6bb860798d864c36a29b3d9ae8d7fc7958c59f88e7", size = 304208 },+ { url = "https://files.pythonhosted.org/packages/c5/16/a5619a9d9bd4601126b95a9026eccfe4ebb74d725b7fdf624680e5a1f502/pypdf-5.6.1-py3-none-any.whl", hash = "sha256:ff09d03d37addbc40f75db3624997a660ff5fe41c61e7ae4db6828dc3f581e4d", size = 304638 },][[package]]