Tasks
For more detailed usage information, please refer to our cookbook: Task Generation Cookbook
1. Concept
In the CAMEL framework, a task is a specific assignment that can be delegated to an agent and resolved by that agent. Tasks represent a higher-level concept than prompts and should be managed by other modules such as the Planner and Workforce. There are two key characteristics of a task:
- A task can be collaborative, requiring multiple agents to work together.
- A task can be decomposed and evolved.
1.1 Task Attributes
Attribute | Type | Description |
---|---|---|
content | string | A clear and concise description of the task at hand. |
id | string | An unique string identifier for the task. |
state | Enum | The task states: “OPEN”, “RUNNING”, “DONE”, “FAILED”, “DELETED”. |
type | string | The type of a task. (TODO) |
parent | Task | The parent task. |
subtasks | A list of Task | A list of sub tasks related the original Task. |
result | string | The Task result. |
1.2 Task Methods
Method | Type | Description |
---|---|---|
from_message | classmethod | Load Task from Message. |
to_message | classmethod | Convert Task to Message. |
reset | instance | Reset Task to initial state. |
update_result | instance | Set task result and mark the task as DONE. |
set_id | instance | Set task id. |
set_state | instance | Recursively set the state of the task and its subtasks. |
add_subtask | instance | Add child task. |
remove_subtask | instance | Delete a subtask by a giving id. |
get_running_task | instance | Get a RUNNING task. |
to_string | instance | Convert task to a string. |
get_result | instance | Get task result to a string. |
decompose | instance | Decompose a task to a list of sub-tasks. |
compose | instance | Compose task result by the sub-tasks. |
get_depth | instance | Get task depth while the root depth is 1. |
2. Get Started
Creating a task involves defining its goal (content) and id:
2.1 Example of Task definition
2.2 Example of multiple Tasks with a hierarchical structure.
3. Decomposing and composing a Task
Decomposing or composing a task involves defining its responsible agent, prompt template and agent response parser. Here is an example:
4. TaskManager
TaskManager is used to manage tasks.
Method | Type | Description |
---|---|---|
topological_sort | instance | Sort a list of tasks topologically. |
set_tasks_dependence | instance | Set relationship between root task and other tasks. Two relationships are currently supported: serial and parallel. |
evolve | instance | Evolve a task to a new task and here it is only used for data generation. |
Example
5. Conclusion
We offers a structured approach to task management, enabling efficient delegation and resolution of tasks by agents. With features such as task decomposition, composition, and hierarchical task structures, CAMEL provides the tools necessary to manage complex workflows. Whether handling simple tasks or intricate, multi-level assignments, CAMEL’s task management capabilities ensure that tasks are executed effectively and collaboratively, enhancing overall productivity.