camel
camel copied to clipboard
[Question] Workforce and Task management for production reasoning agent
Required prerequisites
- [x] I have read the documentation https://camel-ai.github.io/camel/camel.html.
- [x] I have searched the Issue Tracker and Discussions that this hasn't already been reported. (+1 or comment there if it has.)
- [x] Consider asking first in a Discussion.
Questions
I am trying to build a multi-hop agent where the tasks contain subtasks and i want to use the task in a workforce. however it seems that workforce only operates on one task, and refreshes the states when another sub task is passed in. how should i achieve:
- main task 1.1 step1 1.2 step2 1.3 step3
instead of
- main task which you should do step 1 and 2 and 3
for more control and reliability?
Hi, you can structure the Workforce to support context sharing by chaining tasks and passing the result of each step into the additional_info of the next task, as shown below:
import textwrap
# Step 1: Initial Task
step1 = Task(
content="Step 1: Please research and analyze the project.",
additional_info=proj_content,
id="1",
)
# Process Step 1
step1_result = workforce.process_task(step1).result
# Step 2: Use result from Step 1 as additional_info
step2_additional_info = textwrap.dedent(f"""\
Result from Step 1:
{step1_result}
""")
step2 = Task(
content="Step 2: Based on the analysis in Step 1, please perform a technical evaluation.",
additional_info=step2_additional_info,
id="2",
)
# Process Step 2
step2_result = workforce.process_task(step2).result
# Step 3: Use result from Step 2 as additional_info
step3_additional_info = textwrap.dedent(f"""\
Result from Step 2:
{step2_result}
""")
step3 = Task(
content="Step 3: Now, based on the previous steps, please provide a final summary and evaluation.",
additional_info=step3_additional_info,
id="3",
)
# Process Step 3
step3_result = workforce.process_task(step3).result
# Print final result
print("=== Final Summary ===")
print(step3_result)