🐫 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
enhance: workforce fail handling prompt (#3692)
Wendong-Fane8128857b570
diff --git a/.github/ISSUE_TEMPLATE/bug_report.yml b/.github/ISSUE_TEMPLATE/bug_report.ymlindex 13cf207aa..1ccbcb53b 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.83a7+ placeholder: E.g., 0.2.83a8validations:required: truediff --git a/camel/__init__.py b/camel/__init__.pyindex ef0a53e94..5106df330 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.83a7'+__version__ = '0.2.83a8'__all__ = ['__version__',diff --git a/camel/societies/workforce/prompts.py b/camel/societies/workforce/prompts.pyindex b2c464f16..e486b9207 100644--- a/camel/societies/workforce/prompts.py+++ b/camel/societies/workforce/prompts.py@@ -340,12 +340,15 @@ If the task quality is insufficient, select the best recovery strategy from the**DECISION GUIDELINES:**-**Priority Rules:**-1. Connection/Network Errors → **retry** (almost always)-2. Deep Tasks (depth > 2) → Avoid decompose, prefer **retry** or **replan**-3. Worker Skill Mismatch → **reassign** (quality) or **decompose** (failure)-4. Unclear Requirements → **replan** with specifics-5. Task Too Complex → **decompose** into subtasks+**IMPORTANT: You MUST ONLY select from the ENABLED strategies listed above.**+If a strategy is not in the ENABLED list, you CANNOT use it regardless of the guidelines below.++**Priority Rules (apply ONLY if the strategy is ENABLED):**+1. Connection/Network Errors → prefer **retry** if enabled+2. Deep Tasks (depth > 2) → Avoid decompose, prefer **retry** or **replan** if enabled+3. Worker Skill Mismatch → prefer **reassign** (quality) or **decompose** (failure) if enabled, otherwise use **replan**+4. Unclear Requirements → prefer **replan** with specifics if enabled+5. Task Too Complex → prefer **decompose** into subtasks if enabled, otherwise use **replan****RESPONSE FORMAT:**{response_format}@@ -355,7 +358,7 @@ If the task quality is insufficient, select the best recovery strategy from the- No explanations or text outside the JSON structure- Ensure all required fields are included- Use null for optional fields when not applicable-- ONLY use strategies listed above as ENABLED+- **MANDATORY: The recovery_strategy MUST be one of the ENABLED strategies listed above. Using a disabled strategy will cause an error.**""")diff --git a/camel/societies/workforce/workforce.py b/camel/societies/workforce/workforce.pyindex 716570c35..5f4e2c349 100644--- a/camel/societies/workforce/workforce.py+++ b/camel/societies/workforce/workforce.py@@ -4542,15 +4542,29 @@ class Workforce(BaseNode):task, for_failure=True, error_message=detailed_error)- # Fallback to first enabled strategy if no strategy recommended+ # Validate and fallback recovery strategy based on enabled_strategies+ config_strategies = self.failure_handling_config.enabled_strategiesif recovery_decision.recovery_strategy is None:- config_strategies = self.failure_handling_config.enabled_strategies+ # No strategy recommended - use fallback# config_strategies is None means all enabled, use RETRY as default# otherwise use the first enabled strategy from user's configif config_strategies is None:recovery_decision.recovery_strategy = RecoveryStrategy.RETRYelse:recovery_decision.recovery_strategy = config_strategies[0]+ elif config_strategies is not None:+ # Strategy recommended - validate it's in enabled list+ if recovery_decision.recovery_strategy not in config_strategies:+ # LLM recommended a disabled strategy, use first enabled+ recommended = recovery_decision.recovery_strategy.value+ enabled_list = [s.value for s in config_strategies]+ fallback = config_strategies[0].value+ logger.warning(+ f"Task {task.id}: LLM recommended '{recommended}' "+ f"but it's not in enabled_strategies {enabled_list}. "+ f"Using '{fallback}' instead."+ )+ recovery_decision.recovery_strategy = config_strategies[0]strategy_str = recovery_decision.recovery_strategy.valuelogger.info(@@ -5308,11 +5322,12 @@ class Workforce(BaseNode):f"Issues: {', '.join(quality_eval.issues)}")- # Fallback to first enabled strategy if none- # recommended+ # Validate and fallback recovery strategy based on+ # enabled_strategies+ config = self.failure_handling_config+ config_strategies = config.enabled_strategiesif quality_eval.recovery_strategy is None:- config = self.failure_handling_config- config_strategies = config.enabled_strategies+ # No strategy recommended - use fallbackif config_strategies is None:quality_eval.recovery_strategy = (RecoveryStrategy.RETRY@@ -5321,6 +5336,27 @@ class Workforce(BaseNode):quality_eval.recovery_strategy = (config_strategies[0])+ elif config_strategies is not None:+ # Strategy recommended - validate it's enabled+ if (+ quality_eval.recovery_strategy+ not in config_strategies+ ):+ # LLM recommended a disabled strategy+ rec = quality_eval.recovery_strategy.value+ enabled = [+ s.value for s in config_strategies+ ]+ fallback = config_strategies[0].value+ logger.warning(+ f"Task {returned_task.id}: LLM "+ f"recommended '{rec}' but it's not in "+ f"enabled_strategies {enabled}. "+ f"Using '{fallback}' instead."+ )+ quality_eval.recovery_strategy = (+ config_strategies[0]+ )# Preserve assignee before cleanup - in normal# flow, a task must be assigned before it can faildiff --git a/docs/conf.py b/docs/conf.pyindex 8f9d982f5..249e6385d 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.83a7'+release = '0.2.83a8'html_favicon = ('https://raw.githubusercontent.com/camel-ai/camel/master/misc/favicon.png'diff --git a/pyproject.toml b/pyproject.tomlindex 966350125..840d20bb2 100644--- a/pyproject.toml+++ b/pyproject.toml@@ -4,7 +4,7 @@ build-backend = "hatchling.build"[project]name = "camel-ai"-version = "0.2.83a7"+version = "0.2.83a8"description = "Communicative Agents for AI Society Study"authors = [{ name = "CAMEL-AI.org" }]requires-python = ">=3.10,<3.15"diff --git a/uv.lock b/uv.lockindex 10ee5cc52..4100249da 100644--- a/uv.lock+++ b/uv.lock@@ -767,16 +767,16 @@ wheels = [[[package]]name = "botocore"-version = "1.42.26"+version = "1.42.27"source = { registry = "https://pypi.org/simple" }dependencies = [{ name = "jmespath" },{ name = "python-dateutil" },{ name = "urllib3" },]-sdist = { url = "https://files.pythonhosted.org/packages/67/c9/6ce745d4233aeb3abdb18205739b394f7955087f7603cb324a797adbf8d2/botocore-1.42.26.tar.gz", hash = "sha256:1c8855e3e811f015d930ccfe8751d4be295aae0562133d14b6f0b247cd6fd8d3", size = 14882582, upload-time = "2026-01-12T20:36:29.382Z" }+sdist = { url = "https://files.pythonhosted.org/packages/65/90/55b003d38f947c90c0d7e306d377dcdfd9cd0dc1e184082b2d1a6adb0eec/botocore-1.42.27.tar.gz", hash = "sha256:c8e1e3ffb6c871622b1c8054f064d60cbc786aa5ca1f97f5f9fd5fa0a9d82d05", size = 14880030, upload-time = "2026-01-13T20:35:00.31Z" }wheels = [- { url = "https://files.pythonhosted.org/packages/61/43/5993eab2114c0de7bbc21985b745aafe3b912f98fc63726c2a54680bb69d/botocore-1.42.26-py3-none-any.whl", hash = "sha256:71171c2d09ac07739f4efce398b15a4a8bc8769c17fb3bc99625e43ed11ad8b7", size = 14554661, upload-time = "2026-01-12T20:36:26.891Z" },+ { url = "https://files.pythonhosted.org/packages/bf/32/8a4a0447432425cd2f772c757d988742685f46796cf5d68aeaf6bcb6bc37/botocore-1.42.27-py3-none-any.whl", hash = "sha256:d51fb3b8dd1a944c8d238d2827a0dd6e5528d6da49a3bd9eccad019c533e4c9c", size = 14555236, upload-time = "2026-01-13T20:34:55.918Z" },][[package]]@@ -884,7 +884,7 @@ wheels = [[[package]]name = "camel-ai"-version = "0.2.83a7"+version = "0.2.83a8"source = { editable = "." }dependencies = [{ name = "astor" },