Skip to content

armgit / camel

Public Imported from GitHub
0

🐫 CAMEL: The first and the best multi-agent framework. Finding the Scaling Law of Agents. https://www.camel-ai.org

enhance: task decompose prompt for simple task (#2964)

Wendong-Fan562e7c37034e
diff --git a/camel/societies/workforce/prompts.py b/camel/societies/workforce/prompts.py
index c66383503..195995fd3 100644
--- a/camel/societies/workforce/prompts.py
+++ b/camel/societies/workforce/prompts.py
@@ -196,27 +196,32 @@ Now you should summarize the scenario and return the result of the task.
"""
)
-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:
+TASK_DECOMPOSE_PROMPT = r"""You need to either decompose a complex task or enhance a simple one, following these important principles to maximize efficiency and clarity for the executing agents:
-1. **Self-Contained Subtasks**: This is 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.
+0. **Enhance Simple Tasks, Don't Decompose**: First, evaluate if the task is a single, straightforward action.
+ * **If the task is simple, DO NOT decompose it.** Instead, **rewrite and enhance** it by consolidating the main goal with any specific details from the additional information into a single, self-contained instruction. The goal is to produce a high-quality task with a clear, specific deliverable.
+ * For example, a vague task like "Generate a report about camel-ai" should be enhanced to "Generate a comprehensive, well-structured report about camel-ai as one HTML file".
+ * **Only decompose if a task is truly complex**: A task is complex if it involves multiple distinct steps, requires different worker skills, or can be significantly sped up by running parts in parallel.
+
+1. **Self-Contained Subtasks** (if decomposing): This is 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.
-2. **Define Clear Deliverables**: Each subtask must specify a clear, concrete deliverable. This tells the agent exactly what to produce and provides a clear "definition of done."
+2. **Define Clear Deliverables** (for all tasks and subtasks): Each task or subtask must specify a clear, concrete deliverable. This tells the agent exactly what to produce and provides a clear "definition of done."
* **DO NOT** use vague verbs like "analyze," "look into," or "research" without defining the output.
* **DO** specify the format and content of the output. For example, instead of "Analyze the attached report," write "Summarize the key findings of the attached report in a 3-bullet-point list." Instead of "Find contacts," write "Extract all names and email addresses from the document and return them as a JSON list of objects, where each object has a 'name' and 'email' key."
-3. **Full Workflow Completion & Strategic Grouping**:
+3. **Full Workflow Completion & Strategic Grouping** (if decomposing):
* **Preserve the Entire Goal**: Ensure the decomposed subtasks collectively achieve the *entire* original task. Do not drop or ignore final steps like sending a message, submitting a form, or creating a file.
* **Group Sequential Actions**: If a series of steps must be done in order *and* can be handled by the same worker type (e.g., read, think, reply), group them into a single, comprehensive subtask. This maintains workflow and ensures the final goal is met.
-4. **Aggressive Parallelization**:
+4. **Aggressive Parallelization** (if decomposing):
* **Across Different Worker Specializations**: If distinct phases of the overall task require different types of workers (e.g., research by a 'SearchAgent', then content creation by a 'DocumentAgent'), define these as separate subtasks.
* **Within a Single Phase (Data/Task Parallelism)**: If a phase involves repetitive operations on multiple items (e.g., processing 10 documents, fetching 5 web pages, analyzing 3 datasets):
* Decompose this into parallel subtasks, one for each item or a small batch of items.
* This applies even if the same type of worker handles these parallel subtasks. The goal is to leverage multiple available workers or allow concurrent processing.
-5. **Subtask Design for Efficiency**:
+5. **Subtask Design for Efficiency** (if decomposing):
* **Actionable and Well-Defined**: Each subtask should have a clear, achievable goal.
* **Balanced Granularity**: Make subtasks large enough to be meaningful but small enough to enable parallelism and quick feedback. Avoid overly large subtasks that hide parallel opportunities.
* **Consider Dependencies**: While you list tasks sequentially, think about the true dependencies. The workforce manager will handle execution based on these implied dependencies and worker availability.
@@ -225,6 +230,21 @@ These principles aim to reduce overall completion time by maximizing concurrent
**EXAMPLE FORMAT ONLY** (DO NOT use this example content for actual task decomposition):
+***
+**Example 0: Simple Task (Enhance, Don't Decompose)**
+
+* **Overall Task**: "Generate a report about camel-ai"
+* **Available Workers**:
+ * `DocumentAgent`: A worker that can read documents and write summaries.
+* **Correct Output**:
+ ```xml
+ <tasks>
+ <task>Generate a comprehensive, well-structured report about camel-ai as one HTML file</task>
+ </tasks>
+ ```
+* **Reasoning**: The original task is simple but its details are vague. It is **enhanced** by consolidating all given details (output format, content focus) into a single, precise, and self-contained instruction. This follows the "Enhance Simple Tasks" principle and does not invent new information.
+***
+
***
**Example 1: Sequential Task for a Single Worker**