🐫 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: workforce dead lock issue and prompt enhancement (#2833)
Wendong-Fan38b4a50de850
diff --git a/.github/ISSUE_TEMPLATE/bug_report.yml b/.github/ISSUE_TEMPLATE/bug_report.ymlindex e11599cd5..5f7b6b852 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.71a9+ placeholder: E.g., 0.2.71a10validations:required: truediff --git a/camel/__init__.py b/camel/__init__.pyindex 4bff3b408..7397acc12 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.71a9'+__version__ = '0.2.71a10'__all__ = ['__version__',diff --git a/camel/societies/workforce/prompts.py b/camel/societies/workforce/prompts.pyindex 09a083bc0..150730fcf 100644--- a/camel/societies/workforce/prompts.py+++ b/camel/societies/workforce/prompts.py@@ -196,7 +196,11 @@ Now you should summarize the scenario and return the result of the task.""")-WF_TASK_DECOMPOSE_PROMPT = r"""You need to decompose the given task into subtasks according to the workers available in the group, following these important principles to maximize efficiency and parallelism:+TASK_DECOMPOSE_PROMPT = r"""You need to decompose the given task into subtasks according to the workers available in the group, following these important principles to maximize efficiency, parallelism, and clarity for the executing agents:++1. **Self-Contained Subtasks**: This is the most critical principle. Each subtask's description **must be fully self-sufficient and independently understandable**. The agent executing the subtask has **no knowledge** of the parent task, other subtasks, or the overall workflow.+ * **DO NOT** use relative references like "the first task," "the paper mentioned above," or "the result from the previous step."+ * **DO** write explicit instructions. For example, instead of "Analyze the document," write "Analyze the document titled 'The Future of AI'." The system will automatically provide the necessary inputs (like the document itself) from previous steps.1. **Strategic Grouping for Sequential Work**:* If a series of steps must be done in order *and* can be handled by the same worker type, group them into a single subtask to maintain flow and minimize handoffs.@@ -218,17 +222,17 @@ These principles aim to reduce overall completion time by maximizing concurrentIf given a hypothetical task requiring research, analysis, and reporting with multiple items to process, you should decompose it to maximize parallelism:-* Poor decomposition (monolithic):+* Poor decomposition (monolithic and vague):`<tasks><task>Do all research, analysis, and write final report.</task></tasks>`-* Better decomposition (parallel structure):+* **Excellent decomposition (self-contained and parallel)**:```<tasks>- <task>Subtask 1 (ResearchAgent): Gather initial data and resources.</task>- <task>Subtask 2.1 (AnalysisAgent): Analyze Item A from Subtask 1 results.</task>- <task>Subtask 2.2 (AnalysisAgent): Analyze Item B from Subtask 1 results.</task>- <task>Subtask 2.N (AnalysisAgent): Analyze Item N from Subtask 1 results.</task>- <task>Subtask 3 (ReportAgent): Compile all analyses into final report.</task>+ <task>(ResearchAgent): Gather data and resources on topic X, producing a list of relevant items.</task>+ <task>(AnalysisAgent): Analyze the provided document 'Item A'.</task>+ <task>(AnalysisAgent): Analyze the provided document 'Item B'.</task>+ <task>(AnalysisAgent): Analyze the provided document 'Item N'.</task>+ <task>(ReportAgent): Compile the provided analyses of items A, B, and N into a final report.</task></tasks>```@@ -261,10 +265,11 @@ You must return the subtasks as a list of individual subtasks within <tasks> tag</tasks>Each subtask should be:-- Clear and concise-- Achievable by a single worker-- Contain all sequential steps that should be performed by the same worker type-- Only separated from other subtasks when parallel execution by different worker types is beneficial+- **Self-contained and independently understandable.**+- Clear and concise.+- Achievable by a single worker.+- Containing all sequential steps that should be performed by the same worker type.+- Written without any relative references (e.g., "the previous task")."""FAILURE_ANALYSIS_PROMPT = TextPrompt(diff --git a/camel/societies/workforce/worker.py b/camel/societies/workforce/worker.pyindex 5964638df..1fa6e2744 100644--- a/camel/societies/workforce/worker.py+++ b/camel/societies/workforce/worker.py@@ -87,15 +87,9 @@ class Worker(BaseNode, ABC):f"{Fore.YELLOW}{self} get task {task.id}: {task.content}"f"{Fore.RESET}")- # Get the Task instance of dependencies- dependency_ids = await self._channel.get_dependency_ids()- task_dependencies = [- await self._channel.get_task_by_id(dep_id)- for dep_id in dependency_ids- ]# Process the task- task_state = await self._process_task(task, task_dependencies)+ task_state = await self._process_task(task, [])# Update the result and status of the tasktask.set_state(task_state)diff --git a/camel/societies/workforce/workforce.py b/camel/societies/workforce/workforce.pyindex e7f76e255..73e1d0ba1 100644--- a/camel/societies/workforce/workforce.py+++ b/camel/societies/workforce/workforce.py@@ -44,7 +44,7 @@ from camel.societies.workforce.prompts import (ASSIGN_TASK_PROMPT,CREATE_NODE_PROMPT,FAILURE_ANALYSIS_PROMPT,- WF_TASK_DECOMPOSE_PROMPT,+ TASK_DECOMPOSE_PROMPT,)from camel.societies.workforce.role_playing_worker import RolePlayingWorkerfrom camel.societies.workforce.single_agent_worker import SingleAgentWorker@@ -730,7 +730,7 @@ class Workforce(BaseNode):Union[List[Task], Generator[List[Task], None, None]]:The subtasks or generator of subtasks."""- decompose_prompt = WF_TASK_DECOMPOSE_PROMPT.format(+ decompose_prompt = TASK_DECOMPOSE_PROMPT.format(content=task.content,child_nodes_info=self._get_child_nodes_info(),additional_info=task.additional_info,diff --git a/docs/conf.py b/docs/conf.pyindex 2ee84fb3e..ebb004c59 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.71a9'+release = '0.2.71a10'html_favicon = ('https://raw.githubusercontent.com/camel-ai/camel/master/misc/favicon.png'diff --git a/examples/workforce/eigent.py b/examples/workforce/eigent.pyindex a48ef9602..40b354510 100644--- a/examples/workforce/eigent.py+++ b/examples/workforce/eigent.py@@ -207,8 +207,8 @@ def search_agent_factory(available.2. **Browser-Based Exploration**: Use the rich browser toolset toinvestigate websites.- - **Navigation**: Use `visit_page` to open a URL. Navigate with `click`,- `back`, and `forward`. Manage multiple pages with `switch_tab`.+ - **Navigation**: Use `visit_page` to open a URL. Navigate with+ `click`,`back`, and `forward`. Manage multiple pages with `switch_tab`.- **Analysis**: Use `get_som_screenshot` to understand the page layoutand identify interactive elements. Since this is a heavy operation,only use it when visual analysis is necessary.diff --git a/pyproject.toml b/pyproject.tomlindex 5c7ea5b51..d45f71cb4 100644--- a/pyproject.toml+++ b/pyproject.toml@@ -4,7 +4,7 @@ build-backend = "hatchling.build"[project]name = "camel-ai"-version = "0.2.71a9"+version = "0.2.71a10"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 3de413221..1e77bc096 100644--- a/uv.lock+++ b/uv.lock@@ -647,7 +647,7 @@ wheels = [[[package]]name = "camel-ai"-version = "0.2.71a9"+version = "0.2.71a10"source = { editable = "." }dependencies = [{ name = "colorama" },@@ -3234,7 +3234,7 @@ sdist = { url = "https://files.pythonhosted.org/packages/8e/ca/3c4c48c2a180e3410[[package]]name = "ibm-watsonx-ai"-version = "1.3.28"+version = "1.3.30"source = { registry = "https://pypi.org/simple" }dependencies = [{ name = "cachetools" },@@ -3248,9 +3248,9 @@ dependencies = [{ name = "tabulate" },{ name = "urllib3" },]-sdist = { url = "https://files.pythonhosted.org/packages/ca/0d/5c03c406ef2c04928d707784ab695535b64130adad267bb6c74a8b465dcc/ibm_watsonx_ai-1.3.28.tar.gz", hash = "sha256:b66c754320334e0fd5396ec3661344bb621983c0b12d89677fd7afdfdb44ddf0", size = 745752, upload-time = "2025-07-02T17:33:37.516Z" }+sdist = { url = "https://files.pythonhosted.org/packages/61/ba/21bcb1227985a383e5eba3069a8d69e30fc3278d7ce0a478f5f83ebcd677/ibm_watsonx_ai-1.3.30.tar.gz", hash = "sha256:e80ab0d2d603ec3b90b462522d61359055c62638fa29086a2401e54aa79285d5", size = 750357, upload-time = "2025-07-07T15:06:51.578Z" }wheels = [- { url = "https://files.pythonhosted.org/packages/7b/b7/5d38308f22166f3935e686f37a7d40c234bed7c63b7a397b992c51efbf6e/ibm_watsonx_ai-1.3.28-py3-none-any.whl", hash = "sha256:f564e1ddea5728301ed28cdc1fafda2070e3d87522c348d77e09cd419edec9b2", size = 1154449, upload-time = "2025-07-02T17:33:35.783Z" },+ { url = "https://files.pythonhosted.org/packages/6b/33/e54c46d9a42c491119b7c2d267f7d322ac0220e3b1763a969d0ea0e26f21/ibm_watsonx_ai-1.3.30-py3-none-any.whl", hash = "sha256:2bef0cd2d5f3ea83cc37c8993c7c7224f775852f7c5321bd842d03b1eda33bd1", size = 1159977, upload-time = "2025-07-07T15:06:49.745Z" },][[package]]