Tasks
For more detailed usage information, please refer to our cookbook: Task Generation Cookbook
What is a Task in CAMEL?
A task in CAMEL is a structured assignment that can be given to one or more agents. Tasks are higher-level than prompts and managed by modules like the Planner and Workforce.
Key ideas:
- Tasks can be collaborative, requiring multiple agents.
- Tasks can be decomposed into subtasks or evolved over time.
Task Attributes
Attribute | Type | Description |
---|---|---|
content | string | A clear and concise description of the task at hand. |
id | string | A 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 | Subtasks related to the original Task. |
result | string | The Task result. |
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 a child task. |
remove_subtask | instance | Delete a subtask by id. |
get_running_task | instance | Get a RUNNING task. |
to_string | instance | Convert task to a string. |
get_result | instance | Get task result as a string. |
decompose | instance | Decompose a task to a list of subtasks. |
compose | instance | Compose task result by subtasks. |
get_depth | instance | Get task depth; root depth is 1. |
Getting Started: Creating Tasks
Defining a task is simple: specify its content and a unique ID.
Hierarchical Tasks Example
You can build nested, hierarchical tasks using subtasks. Here’s an example:
Decomposing and Composing a Task
You can break down (decompose) a task into smaller subtasks, or compose the results from subtasks. Typically, you define an agent, prompt template, and response parser.
TaskManager
TaskManager Overview
The TaskManager class helps you manage, sort, and evolve tasks—handling dependencies and progression automatically.
Method | Type | Description |
---|---|---|
topological_sort | instance | Sort a list of tasks topologically. |
set_tasks_dependence | instance | Set relationship between root task and other tasks (serial or parallel). |
evolve | instance | Evolve a task to a new task; used for data generation. |
Conclusion
CAMEL offers a powerful, structured approach to task management. With support for task decomposition, composition, and deep hierarchies, you can automate everything from simple workflows to complex, multi-agent projects. Efficient, collaborative, and easy to integrate—this is next-level task orchestration for AI.